繁体   English   中英

WCF服务方法无法引用实体作为参数

[英]WCF- service method fails to reference entity as parameter

我附带了WSDL,我需要使用Visual Studio 2013,WCF和.NET 4.5生成客户端存根。 我得到一个object []参数,而不是签名中的预期参数BoolExpression。生成的getResourceList服务方法如下所示:

public TestFieldSOAP.ServiceReference1.ResourceWrapper[] getResourceList(long arg0, long arg1, object[] arg2, object[] arg3)

它看起来应该像这样:

public TestFieldSOAP.ServiceReference1.ResourceWrapper[] getResourceList(long arg0, long arg1, BoolExpression be, object[] arg3)

简而言之,实体BoolExpression是在模式中定义的,但在方法中未作为参数引用。 我已经对WSDL和XSD进行了很多研究,但是到目前为止,我还没有找到答案。

有任何想法吗?

WSDL

<?xml version="1.0" ?>
<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:tns="http://ResourceManagementBasic.webservices.xxx.com/"
    xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:ns3="http://schemas.xmlsoap.org/soap/http"
    xmlns:ns2="http://security.lowLevel.hello.webservices.xxx.com/"
    xmlns:ns1="http://ResourceManagement.hello.xxx.com/" name="WSResourceAdmin_v15Service"
    targetNamespace="http://ResourceManagementBasic.webservices.xxx.com/">
    <wsdl:types>
        <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:tns="http://hello.xxx.com/" elementFormDefault="qualified"
            targetNamespace="http://hello.xxx.com/" version="1.0">
            <xs:complexType name="BoolExpression">
                <xs:sequence>
                    <xs:element maxOccurs="unbounded" name="expressions"
                        nillable="true" type="xs:anyType"></xs:element>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="AttributeOperatorValueExpression">
                <xs:complexContent>
                    <xs:extension base="tns:BoolExpression">
                        <xs:sequence>
                            <xs:element name="attribute" nillable="true" type="xs:string"></xs:element>
                            <xs:element name="operator" nillable="true" type="xs:string"></xs:element>
                            <xs:element name="value" nillable="true" type="xs:anyType"></xs:element>
                        </xs:sequence>
                    </xs:extension>
                </xs:complexContent>
            </xs:complexType>
            <xs:complexType name="ANDExpression">
                <xs:complexContent>
                    <xs:extension base="tns:BoolExpression">
                        <xs:sequence></xs:sequence>
                    </xs:extension>
                </xs:complexContent>
            </xs:complexType>
            <xs:complexType name="Wrapper">
                <xs:sequence>
                    <xs:element maxOccurs="unbounded" name="value" nillable="true"
                        type="xs:anyType"></xs:element>
                </xs:sequence>
            </xs:complexType>
        </xs:schema>

        <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://Wrappers.hello.xxx.com" version="1.0">
            <xs:complexType name="ResourceWrapper">
                <xs:sequence>
                    <xs:element form="qualified" name="Resource" nillable="true" type="xs:long"></xs:element>           
                </xs:sequence>
            </xs:complexType>
        </xs:schema>

        <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:tns="http://ResourceManagementBasic.webservices.xxx.com/"
            xmlns:ns6="http://Wrappers.hello.xxx.com"  xmlns:ns1="http://hello.xxx.com/"
            attributeFormDefault="unqualified" elementFormDefault="unqualified"
            targetNamespace="http://ResourceManagementBasic.webservices.xxx.com/">
            <xs:import namespace="http://hello.xxx.com/"></xs:import>
            <xs:import namespace="http://Wrappers.hello.xxx.com"></xs:import>
            <xs:element name="getResourceList" type="tns:getResourceList"></xs:element>
            <xs:element name="getResourceListResponse" type="tns:getResourceListResponse"></xs:element>
            <xs:complexType name="getResourceListResponse">
                <xs:sequence>
                    <xs:element maxOccurs="unbounded" minOccurs="0" name="return"
                        type="ns6:ResourceWrapper"></xs:element>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="getResourceList">
                <xs:sequence>
                    <xs:element minOccurs="0" name="arg0" type="xs:long"></xs:element>
                    <xs:element minOccurs="0" name="arg1" type="xs:long"></xs:element>
                    <xs:element minOccurs="0" name="arg2" type="ns1:BoolExpression" form="qualified"></xs:element>
                    <xs:element maxOccurs="unbounded" minOccurs="0" name="arg3" type="xs:anyType"></xs:element>
                </xs:sequence>
            </xs:complexType>   
        </xs:schema>
    </wsdl:types>


    <wsdl:message name="getResourceListResponse">
        <wsdl:part element="tns:getResourceListResponse" name="parameters">
        </wsdl:part>
    </wsdl:message>
    <wsdl:message name="getResourceList">
        <wsdl:part element="tns:getResourceList" name="parameters">
        </wsdl:part>
    </wsdl:message>

    <wsdl:portType name="WSResourceAdmin_v15">
        <wsdl:operation name="getResourceList">
            <wsdl:input message="tns:getResourceList" name="getResourceList">
            </wsdl:input>
            <wsdl:output message="tns:getResourceListResponse" name="getResourceListResponse">
            </wsdl:output>
        </wsdl:operation>
    </wsdl:portType>    


    <wsdl:binding name="WSResourceAdmin_v15ServiceSoapBinding"
        type="tns:WSResourceAdmin_v15">
        <soap12:binding style="document"
            transport="http://schemas.xmlsoap.org/soap/http"></soap12:binding>
        <wsdl:operation name="getResourceList">
            <soap12:operation soapAction="" style="document"></soap12:operation>
            <wsdl:input name="getResourceList">
                <soap12:body use="literal"></soap12:body>
            </wsdl:input>
            <wsdl:output name="getResourceListResponse">
                <soap12:body use="literal"></soap12:body>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>


    <wsdl:service name="WSResourceAdmin_v15Service">
        <wsdl:port binding="tns:WSResourceAdmin_v15ServiceSoapBinding"
            name="WSResourceAdmin_v15Port">
            <soap12:address
                location="xxx"></soap12:address>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

这也是生成的getResource方法存根的方法签名

[System.Xml.Serialization.XmlArrayItemAttribute("expressions", Namespace="http://hello.xxx.com/")]
        public object[] arg2 {

编辑2016年2月8日
看来有效的修正是正确的:object []是BoolExpression类型内定义的anyType序列的结果。 我读到删除对BoolExpression命名空间的导入将导致svcutil生成器将BoolExpression作为参数包含在生成的方法中。 这行得通吗? 还是建议使用其他解决方法? 由于我是从一个.NET错误运行到另一个错误,因此我当时无法测试我的假设

它是wsdl定义的方式。 类型=“ **:anyType”的元素将映射到Object对象。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM