Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to consume a ColdFusion web service with dotnet

I'm not experienced at all in SOAP and web services. I'm trying to call a ColdFusion web service from C# (.NET 4.0). I'm generating a proxy from the WSDL with svcutil.exe. The web service works when I call ListCases from SoapUI, but when I call it from the proxy I get a map with a single mapItem, and that mapItem has null item and value. I would guess that this isn't working because the WSDL doesn't include a definition for QueryBean. If this is the problem I'll try and get the author of the web service to add the definition, otherwise do I have any options other than parsing the XML manually?

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

and the result(I've modified it so as to have a shorter list of data and to not contain confidential information)

<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>
like image 432
Doug Wilson Avatar asked Nov 05 '22 04:11

Doug Wilson


1 Answers

yes looks like the WSDL doesnt have the ns3:QueryBean type defined and the proxy cant de-serialize it to that type; The best option would be ask the author of the webservice to provide you with all the necessary types. They must have already defined all the types at their end so it might be easier to get their XSD's that have the type definitions or a WSDL that contains the types.

In a case where they are dynamically generating random types (eg: QueryBean, Foo, Foobar) etc then you might be out of luck and in that case there is no other way than manually traversing the xml.

like image 120
Ricky Gummadi Avatar answered Nov 09 '22 11:11

Ricky Gummadi