2012-03-09 9 views
6

Non ho alcuna esperienza in SOAP e nei servizi Web. Sto cercando di chiamare un servizio web ColdFusion da C# (.NET 4.0). Sto generando un proxy dal WSDL con svcutil.exe. Il servizio web funziona quando chiamo ListCases da SoapUI, ma quando lo chiamo dal proxy ottengo una mappa con un singolo mapItem e che mapItem ha oggetti e valori nulli. Direi che questo non funziona perché il WSDL non include una definizione per QueryBean. Se questo è il problema, cercherò di ottenere l'autore del servizio web per aggiungere la definizione, altrimenti ho altre opzioni oltre all'analisi manuale dell'XML?Come utilizzare un servizio Web ColdFusion con 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> 

e il risultato (che ho modificato in modo da avere un elenco più breve dei dati e di non contengano informazioni riservate)

<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> 

risposta

2

sì sembra che il WSDL doesnt hanno la NS3: QueryBean tipo definito e il proxy non può serializzarlo su quel tipo; L'opzione migliore sarebbe chiedere all'autore del webservice di fornirti tutti i tipi necessari. Devono aver già definito tutti i tipi alla loro fine, quindi potrebbe essere più facile ottenere i loro XSD che hanno le definizioni di tipo o un WSDL che contiene i tipi.

In un caso in cui generano dinamicamente tipi casuali (ad es. QueryBean, Foo, Foobar) ecc. Allora si può essere sfortunati e in tal caso non c'è altro modo che attraversare manualmente l'xml.

Problemi correlati