从wsdl返回通用对象生成的客户机代码

时间:2019-12-10 21:57:58

标签: c# .net visual-studio wsdl svcutil.exe

从wsdl生成的客户端代码具有多个服务调用,这些服务调用返回由XmlNode []组成的通用对象,而不是预期的类型,例如caseSearch返回caseSearchResponse。 XmlNode []的最后一个元素包含应反序列化到类型化对象实例中的xml。

我已经使用Visual Studio添加引用向导(没有运气)切换并重新生成了具有不同设置的代码。我试图手动调整文件,但是对我在做什么几乎一无所知,但似乎无法正常工作。我也尝试过svcutil生成类,但是输出是相同的。

我认为我可以直接从xml节点反序列化,但是我担心此解决方法只能是一个临时解决方案,其他问题直到稍后都不会被发现。

由于长度限制,我只能发布此代码的一部分,因此我只做与caseSearch调用相关的部分。

wsdl文件:

.replace(/__prefix__/g, form_idx)

和相关的xsd文件:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.4-b01-. -->
<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.4-b01-. -->
<definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="urn:greenfiling:partner:ws:schema:FilingInfo" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="urn:greenfiling:partner:ws:schema:FilingInfo" name="FilingInfoService">
<types>
<xsd:schema>
<xsd:import namespace="urn:greenfiling:partner:ws:schema:common" schemaLocation="https://dev.greenfiling.com:443/ildev/filingInfo?xsd=1"/>
</xsd:schema>
<xsd:schema>
<xsd:import namespace="urn:greenfiling:partner:ws:schema:SingleSignOn" schemaLocation="https://dev.greenfiling.com:443/ildev/filingInfo?xsd=2"/>
</xsd:schema>
<xsd:schema>
<xsd:import namespace="urn:greenfiling:partner:ws:schema:FilingInfo" schemaLocation="https://dev.greenfiling.com:443/ildev/filingInfo?xsd=3"/>
</xsd:schema>
</types>
<message name="caseSearch">
<part name="parameters" element="tns:caseSearch"/>
</message>
<message name="caseSearchResponse">
<part name="parameters" element="tns:caseSearchResponse"/>
</message>
<portType name="FilingInfo">
<operation name="caseSearch">
<input message="tns:caseSearch"/>
<output message="tns:caseSearchResponse"/>
</operation>
</portType>
<binding name="FilingInfoPortBinding" type="tns:FilingInfo">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="caseSearch">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="FilingInfoService">
<port name="FilingInfoPort" binding="tns:FilingInfoPortBinding">
<soap:address location="https://dev.greenfiling.com:443/ildev/filingInfo"/>
</port>
</service>
<script xmlns=""/>
</definitions>

生成的客户端代码:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:ns1="urn:greenfiling:partner:ws:schema:SingleSignOn" xmlns:tns="urn:greenfiling:partner:ws:schema:FilingInfo" xmlns:ns2="urn:greenfiling:partner:ws:schema:common" targetNamespace="urn:greenfiling:partner:ws:schema:FilingInfo" version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:import schemaLocation="https://dev.greenfiling.com:443/ildev/filingInfo?xsd=2" namespace="urn:greenfiling:partner:ws:schema:SingleSignOn" />
  <xs:import schemaLocation="https://dev.greenfiling.com:443/ildev/filingInfo?xsd=1" namespace="urn:greenfiling:partner:ws:schema:common" />
  <xs:element name="caseSearch" type="tns:caseSearch" />
  <xs:element name="caseSearchRequest" type="tns:caseSearchRequestType" />
  <xs:element name="caseSearchResponse" nillable="true" type="xs:anyType" />
  <xs:complexType name="caseSearch">
    <xs:sequence>
      <xs:element minOccurs="0" ref="tns:caseSearchRequest" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="caseSearchRequestType">
    <xs:sequence>
      <xs:element minOccurs="0" form="qualified" name="attorney" type="ns2:user" />
      <xs:element minOccurs="0" form="qualified" name="courtCode" type="xs:string" />
      <xs:element minOccurs="0" form="qualified" name="caseNumber" type="xs:string" />
      <xs:element minOccurs="0" form="qualified" name="partyName" type="xs:string" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="caseSearchResponse">
    <xs:sequence>
      <xs:element minOccurs="0" ref="tns:caseSearchResponse" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="caseSearchResponseType">
    <xs:sequence>
      <xs:element minOccurs="0" form="qualified" name="responseObject" type="ns1:ResponseObject" />
      <xs:element minOccurs="0" name="courtCases">
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="0" maxOccurs="unbounded" form="qualified" name="courtCase" type="ns2:case" />
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
</xs:schema>

我认为这就是一切,但是请告诉我是否可以提供更多有用的详细信息。 我真的很感谢任何指导!

0 个答案:

没有答案