2012-03-09 37 views
6

Tôi không có kinh nghiệm trong tất cả các dịch vụ web và SOAP. Tôi đang cố gắng gọi một dịch vụ web ColdFusion từ C# (.NET 4.0). Tôi đang tạo một proxy từ WSDL với svcutil.exe. Các dịch vụ web hoạt động khi tôi gọi ListCases từ SoapUI, nhưng khi tôi gọi nó từ proxy tôi nhận được một bản đồ với một mapItem duy nhất, và mapItem đó có null item và value. Tôi đoán rằng điều này không hoạt động vì WSDL không bao gồm định nghĩa cho QueryBean. Nếu đây là vấn đề tôi sẽ cố gắng và làm cho tác giả của dịch vụ web thêm định nghĩa, nếu không thì tôi có bất kỳ tùy chọn nào khác ngoài phân tích cú pháp XML theo cách thủ công không?Cách sử dụng dịch vụ web ColdFusion với dotnet

<wsdl:definitions xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://syndication.v63" xmlns:intf="http://syndication.v63" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns1="http://rpc.xml.coldfusion" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://syndication.v63"> 
    <!-- WSDL created by ColdFusion version 9,0,1,274733 --> 
    <wsdl:types> 
    <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://xml.apache.org/xml-soap"> 
     <import namespace="http://rpc.xml.coldfusion"/> 
     <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/> 
     <complexType name="mapItem"> 
     <sequence> 
      <element name="key" nillable="true" type="xsd:anyType"/> 
      <element name="value" nillable="true" type="xsd:anyType"/> 
     </sequence> 
     </complexType> 
     <complexType name="Map"> 
     <sequence> 
      <element maxOccurs="unbounded" minOccurs="0" name="item" type="apachesoap:mapItem"/> 
     </sequence> 
     </complexType> 
    </schema> 
    <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://rpc.xml.coldfusion"> 
     <import namespace="http://xml.apache.org/xml-soap"/> 
     <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/> 
     <complexType name="CFCInvocationException"> 
     <sequence/> 
     </complexType> 
    </schema> 
    </wsdl:types> 
    <wsdl:message name="ListCasesResponse"> 
    <wsdl:part name="ListCasesReturn" type="apachesoap:Map"/> 
    </wsdl:message> 
    <wsdl:message name="FolderDetailsResponse"> 
    <wsdl:part name="FolderDetailsReturn" type="apachesoap:Map"/> 
    </wsdl:message> 
    <wsdl:message name="ListBoxesRequest"> 
    <wsdl:part name="CaseDatabase" type="xsd:string"/> 
    <wsdl:part name="Prefix" type="xsd:string"/> 
    </wsdl:message> 
    <wsdl:message name="ListFoldersRequest"> 
    <wsdl:part name="CaseDatabase" type="xsd:string"/> 
    <wsdl:part name="Prefix" type="xsd:string"/> 
    <wsdl:part name="Box" type="xsd:string"/> 
    </wsdl:message> 
    <wsdl:message name="CFCInvocationException"> 
    <wsdl:part name="fault" type="tns1:CFCInvocationException"/> 
    </wsdl:message> 
    <wsdl:message name="ListPrefixesRequest"> 
    <wsdl:part name="CaseDatabase" type="xsd:string"/> 
    </wsdl:message> 
    <wsdl:message name="ListFoldersResponse"> 
    <wsdl:part name="ListFoldersReturn" type="apachesoap:Map"/> 
    </wsdl:message> 
    <wsdl:message name="ListPrefixesResponse"> 
    <wsdl:part name="ListPrefixesReturn" type="apachesoap:Map"/> 
    </wsdl:message> 
    <wsdl:message name="FolderDetailsRequest"> 
    <wsdl:part name="CaseDatabase" type="xsd:string"/> 
    <wsdl:part name="Prefix" type="xsd:string"/> 
    <wsdl:part name="Box" type="xsd:string"/> 
    <wsdl:part name="Folder" type="xsd:string"/> 
    </wsdl:message> 
    <wsdl:message name="ListCasesRequest"></wsdl:message> 
    <wsdl:message name="ListBoxesResponse"> 
    <wsdl:part name="ListBoxesReturn" type="apachesoap:Map"/> 
    </wsdl:message> 
    <wsdl:portType name="Ricoh_syndication"> 
    <wsdl:operation name="ListCases"> 
     <wsdl:input message="impl:ListCasesRequest" name="ListCasesRequest"/> 
     <wsdl:output message="impl:ListCasesResponse" name="ListCasesResponse"/> 
     <wsdl:fault message="impl:CFCInvocationException" name="CFCInvocationException"/> 
    </wsdl:operation> 
    <wsdl:operation name="FolderDetails" parameterOrder="CaseDatabase Prefix Box Folder"> 
     <wsdl:input message="impl:FolderDetailsRequest" name="FolderDetailsRequest"/> 
     <wsdl:output message="impl:FolderDetailsResponse" name="FolderDetailsResponse"/> 
     <wsdl:fault message="impl:CFCInvocationException" name="CFCInvocationException"/> 
    </wsdl:operation> 
    <wsdl:operation name="ListFolders" parameterOrder="CaseDatabase Prefix Box"> 
     <wsdl:input message="impl:ListFoldersRequest" name="ListFoldersRequest"/> 
     <wsdl:output message="impl:ListFoldersResponse" name="ListFoldersResponse"/> 
     <wsdl:fault message="impl:CFCInvocationException" name="CFCInvocationException"/> 
    </wsdl:operation> 
    <wsdl:operation name="ListPrefixes" parameterOrder="CaseDatabase"> 
     <wsdl:input message="impl:ListPrefixesRequest" name="ListPrefixesRequest"/> 
     <wsdl:output message="impl:ListPrefixesResponse" name="ListPrefixesResponse"/> 
     <wsdl:fault message="impl:CFCInvocationException" name="CFCInvocationException"/> 
    </wsdl:operation> 
    <wsdl:operation name="ListBoxes" parameterOrder="CaseDatabase Prefix"> 
     <wsdl:input message="impl:ListBoxesRequest" name="ListBoxesRequest"/> 
     <wsdl:output message="impl:ListBoxesResponse" name="ListBoxesResponse"/> 
     <wsdl:fault message="impl:CFCInvocationException" name="CFCInvocationException"/> 
    </wsdl:operation> 
    </wsdl:portType> 
    <wsdl:binding name="ricoh_syndication.cfcSoapBinding" type="impl:Ricoh_syndication"> 
    <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> 
    <wsdl:operation name="ListCases"> 
     <wsdlsoap:operation soapAction=""/> 
     <wsdl:input name="ListCasesRequest"> 
     <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://syndication.v63" use="encoded"/> 
     </wsdl:input> 
     <wsdl:output name="ListCasesResponse"> 
     <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://syndication.v63" use="encoded"/> 
     </wsdl:output> 
     <wsdl:fault name="CFCInvocationException"> 
     <wsdlsoap:fault encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" name="CFCInvocationException" namespace="http://syndication.v63" use="encoded"/> 
     </wsdl:fault> 
    </wsdl:operation> 
    <wsdl:operation name="FolderDetails"> 
     <wsdlsoap:operation soapAction=""/> 
     <wsdl:input name="FolderDetailsRequest"> 
     <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://syndication.v63" use="encoded"/> 
     </wsdl:input> 
     <wsdl:output name="FolderDetailsResponse"> 
     <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://syndication.v63" use="encoded"/> 
     </wsdl:output> 
     <wsdl:fault name="CFCInvocationException"> 
     <wsdlsoap:fault encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" name="CFCInvocationException" namespace="http://syndication.v63" use="encoded"/> 
     </wsdl:fault> 
    </wsdl:operation> 
    <wsdl:operation name="ListFolders"> 
     <wsdlsoap:operation soapAction=""/> 
     <wsdl:input name="ListFoldersRequest"> 
     <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://syndication.v63" use="encoded"/> 
     </wsdl:input> 
     <wsdl:output name="ListFoldersResponse"> 
     <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://syndication.v63" use="encoded"/> 
     </wsdl:output> 
     <wsdl:fault name="CFCInvocationException"> 
     <wsdlsoap:fault encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" name="CFCInvocationException" namespace="http://syndication.v63" use="encoded"/> 
     </wsdl:fault> 
    </wsdl:operation> 
    <wsdl:operation name="ListPrefixes"> 
     <wsdlsoap:operation soapAction=""/> 
     <wsdl:input name="ListPrefixesRequest"> 
     <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://syndication.v63" use="encoded"/> 
     </wsdl:input> 
     <wsdl:output name="ListPrefixesResponse"> 
     <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://syndication.v63" use="encoded"/> 
     </wsdl:output> 
     <wsdl:fault name="CFCInvocationException"> 
     <wsdlsoap:fault encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" name="CFCInvocationException" namespace="http://syndication.v63" use="encoded"/> 
     </wsdl:fault> 
    </wsdl:operation> 
    <wsdl:operation name="ListBoxes"> 
     <wsdlsoap:operation soapAction=""/> 
     <wsdl:input name="ListBoxesRequest"> 
     <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://syndication.v63" use="encoded"/> 
     </wsdl:input> 
     <wsdl:output name="ListBoxesResponse"> 
     <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://syndication.v63" use="encoded"/> 
     </wsdl:output> 
     <wsdl:fault name="CFCInvocationException"> 
     <wsdlsoap:fault encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" name="CFCInvocationException" namespace="http://syndication.v63" use="encoded"/> 
     </wsdl:fault> 
    </wsdl:operation> 
    </wsdl:binding> 
    <wsdl:service name="Ricoh_syndicationService"> 
    <wsdl:port binding="impl:ricoh_syndication.cfcSoapBinding" name="ricoh_syndication.cfc"> 
     <wsdlsoap:address location="https://www2.delium.com/v6-3/syndication/ricoh_syndication.cfc"/> 
    </wsdl:port> 
    </wsdl:service> 
</wsdl:definitions> 

và kết quả (Tôi đã sửa đổi nó để có một danh sách ngắn của dữ liệu và không chứa thông tin bí mật)

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <soapenv:Body> 
     <ns1:ListCasesResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://syndication.v63"> 
     <ListCasesReturn xsi:type="ns2:Map" xmlns:ns2="http://xml.apache.org/xml-soap"> 
      <item xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"> 
       <key xsi:type="soapenc:string">RETURNCODE</key> 
       <value xsi:type="soapenc:string">1</value> 
      </item> 
      <item> 
       <key xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">RETURNTEXT</key> 
       <value xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">Success (1)</value> 
      </item> 
      <item> 
       <key xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">OUTPUTS</key> 
       <value xsi:type="ns2:Map"> 
        <item xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"> 
        <key xsi:type="soapenc:string">QCASES</key> 
        <value xsi:type="ns3:QueryBean" xmlns:ns3="http://rpc.xml.coldfusion"> 
         <columnList soapenc:arrayType="xsd:string[2]" xsi:type="soapenc:Array"> 
          <columnList xsi:type="xsd:string">CASENAME</columnList> 
          <columnList xsi:type="xsd:string">CASEDATABASE</columnList> 
         </columnList> 
         <data soapenc:arrayType="xsd:anyType[][35]" xsi:type="soapenc:Array"> 
          <data soapenc:arrayType="xsd:anyType[2]" xsi:type="soapenc:Array"> 
           <data xsi:type="soapenc:string">test1</data> 
           <data xsi:type="soapenc:string">test2</data> 
          </data> 
         </data> 
        </value> 
        </item> 
        <item> 
        <key xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">REMOTEIPADDRESS</key> 
        <value xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">219.89.202.100</value> 
        </item> 
       </value> 
      </item> 
     </ListCasesReturn> 
     </ns1:ListCasesResponse> 
    </soapenv:Body> 
</soapenv:Envelope> 

Trả lời

2

có vẻ như WSDL doesnt có ns3: QueryBean loại được xác định và proxy không thể loại bỏ nó thành loại đó; Tùy chọn tốt nhất sẽ yêu cầu tác giả của webservice cung cấp cho bạn tất cả các loại cần thiết. Họ phải đã xác định tất cả các loại ở cuối của chúng để có thể dễ dàng hơn để có được các XSD của chúng có các định nghĩa kiểu hoặc một WSDL chứa các kiểu.

Trong trường hợp chúng tự động tạo các loại ngẫu nhiên (ví dụ: QueryBean, Foo, Foobar) vv thì bạn có thể không may mắn và trong trường hợp đó không có cách nào khác hơn là di chuyển ngang qua xml.

Các vấn đề liên quan