未生成simpleType的代理

时间:2013-05-27 16:43:18

标签: c# web-services wsdl proxy-classes

我通过右键单击“服务引用”并输入包含wsdl的URL来在VS中创建服务引用。

它有点工作,但属性AddRobinsonEntryRequest.subscriberEmails创建为字符串。它应该是EmailAddress类型的数组。

我使用XMLSpy验证了wsdl,并且声明它是有效的。

如果我在VS中打开同一个文件,我会收到错误:未定义类型http://backclick.de/rpc/soap/schemas/types/types:ListOfEmailAddress

第9行

这里是wsdl:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:sch0="http://backclick.de/rpc/soap/schemas/messages" xmlns:sch1="http://backclick.de/rpc/soap/schemas/types" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://backclick.de/rpc/soap/schemas/types" targetNamespace="http://backclick.de/rpc/soap/schemas/types">
    <wsdl:types>
        <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://backclick.de/rpc/soap/schemas/messages" xmlns:types="http://backclick.de/rpc/soap/schemas/types" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://backclick.de/rpc/soap/schemas/messages">
            <import namespace="http://backclick.de/rpc/soap/schemas/types"/>
            <element name="AddRobinsonEntryRequest">
                <complexType>
                    <all>
                        <element name="subscriberEmails" type="types:ListOfEmailAddress"/>
                    </all>
                </complexType>
            </element>
            <element name="AddRobinsonEntryResponse">
                <complexType>
                    <sequence>
                        <element name="success" type="boolean"/>
                    </sequence>
                </complexType>
            </element>
        </schema>
        <schema xmlns="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://backclick.de/rpc/soap/schemas/types">
            <simpleType name="ListOfEmailAddress">
                <list itemType="tns:EmailAddress"/>
            </simpleType>
            <simpleType name="EmailAddress">
                <restriction base="string">
                    <pattern value="[a-z0-9!#$%&amp;'*+/=?^_`{|}~-]+(\.[a-z0-9!#$%&amp;'*+/=?^_`{|}~-]+)*@([a-z0-9]([a-z0-9-]*[a-z0-9])?\.)+[a-z0-9]([a-z0-9-]*[a-z0-9])?"/>
                </restriction>
            </simpleType>
        </schema>
    </wsdl:types>
    <wsdl:message name="AddRobinsonEntryResponse">
        <wsdl:part name="AddRobinsonEntryResponse" element="sch0:AddRobinsonEntryResponse"/>
    </wsdl:message>
    <wsdl:message name="AddRobinsonEntryRequest">
        <wsdl:part name="AddRobinsonEntryRequest" element="sch0:AddRobinsonEntryRequest"/>
    </wsdl:message>
    <wsdl:portType name="BackclickService">
        <wsdl:operation name="AddRobinsonEntry">
            <wsdl:input name="AddRobinsonEntryRequest" message="sch1:AddRobinsonEntryRequest"/>
            <wsdl:output name="AddRobinsonEntryResponse" message="sch1:AddRobinsonEntryResponse"/>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="BackclickServiceSoap11" type="tns:BackclickService">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="AddRobinsonEntry">
            <soap:operation soapAction=""/>
            <wsdl:input name="AddRobinsonEntryRequest">
                <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output name="AddRobinsonEntryResponse">
                <soap:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="BackclickServiceService">
        <wsdl:port name="BackclickServiceSoap11" binding="tns:BackclickServiceSoap11">
            <soap:address location="http://asp.backclick.de:80/bc/rpc/soap"/>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

这是生成的代理类:

  public partial class AddRobinsonEntryRequest : object, System.ComponentModel.INotifyPropertyChanged {

        private string subscriberEmailsField;

        /// <remarks/>
        public string subscriberEmails {
            get {
                return this.subscriberEmailsField;
            }
            set {
                this.subscriberEmailsField = value;
                this.RaisePropertyChanged("subscriberEmails");
            }
        }

如何将subscriberEmailsField生成为数组?

1 个答案:

答案 0 :(得分:0)

我误读了wsdl。 subscriberEmails真的期望一个字符串。 ListOfEmailAddress不是数组,而是格式为“mail1@domain.com mail1@domain.com mail2@domain.com”的字符串