0

I usually consume SOAP webservices with CFHTTP and post the XML as a HTTP parameter. However, this time I am trying to consume a webservice with createObject, but when I pass the XML as an argument to the webservice ws.someMethod(args);, it fails. I tried using a struct to hold the parameter values, but that also did not work. As such, how do one pass the parameters? The partial WSDL is below

            <xs:element name="ORDER">
            <xs:complexType>
                <xs:sequence>
                    <xs:element name="Header" type="schemaOne:HeaderType"/>
                    <xs:element maxOccurs="unbounded" name="Detail" type="schemaOne:DetailType"/>
                </xs:sequence>
            </xs:complexType>
        </xs:element>
        <xs:complexType name="DetailType">
            <xs:sequence>
                <xs:element ref="schemaOne:DTORDN"/>
                <xs:element ref="schemaOne:DTRCID"/>
                <xs:element ref="schemaOne:DTPRT"/>
                <xs:element ref="schemaOne:DTQTY"/>
                <xs:element ref="schemaOne:DTNTU"/>
            </xs:sequence>
        </xs:complexType>
        <xs:complexType name="HeaderType">
            <xs:sequence>
                <xs:element ref="schemaOne:DSORDN"/>
                <xs:element ref="schemaOne:DSRCID"/>
                <xs:element ref="schemaOne:DSBFNM"/>
                <xs:element ref="schemaOne:DSBLNM"/>
                <xs:element minOccurs="0" ref="schemaOne:DSBENT"/>
                <xs:element ref="schemaOne:DSBAD1"/>
                <xs:element minOccurs="0" ref="schemaOne:DSBAD2"/>
                <xs:element minOccurs="0" ref="schemaOne:DSBAD3"/>
                <xs:element ref="schemaOne:DSBAD4"/>
                <xs:element ref="schemaOne:DSBSTT"/>
                <xs:element ref="schemaOne:DSBZIP"/>
                <xs:element ref="schemaOne:DSBCNT"/>
             </xs:sequence>
       </xs:complexType>

Here's the struct I've constructed.

<cfscript>
  ORDER = {};
  ORDER.Header = {};
  ORDER.Detail = {};
  ORDER.Header.DSORDN = '251716';
  ORDER.Header.DSRCID = 'H';
  ORDER.Header.DSBFNM = 'Joe';
  ORDER.Header.DSBLNM = 'Smith';
  ORDER.Header.DSBAD1 = '4997 County Road';
  ORDER.Header.DSBAD4 = 'Springfield';
  ORDER.Header.DSBSTT = 'MO';
  ORDER.Header.DSBZIP = '49657';
  ORDER.Header.DSBCNT = 'USA';
  ORDER.Detail.DTORDN = '251716';
  ORDER.Detail.DTRCID = 'D';
  ORDER.Detail.DTPRT = '0300604';
  ORDER.Detail.DTQTY = '0000000000001';
  ORDER.Detail.DTNTU = '00000009.9900';
</cfscript>
RHPT
  • 2,560
  • 5
  • 31
  • 43

2 Answers2

0

You have to consume SOAP web services that expect complex data type with CFC that mirrors the expected structure instead of passing the XML. See this

NathanOliver
  • 171,901
  • 28
  • 288
  • 402
Henry
  • 32,689
  • 19
  • 120
  • 221
0

i am working with unit tests at the moment and where trying to pass an xml file to my Webservice. I just saved the xml Files i needed inside external files and read them with "FileRead" inside cfscript. This is how i did it

<cfscript>

    input = FileRead("http.....");

    mycomponent = createObject("component", "component.beginning.from.root");
    mycomponent.methodName(input);

</cfscript>

but i had to change my code because before i parsed the content of the HttpRequest to xml and where looking for the expected elements. Now i use the incoming file and look immediately for the elements i want instead of parsing because its already xml

<cfset var body = xmlsearch(arguments.input, "//soapenv:body")[1] />

if you're interested in the code of my webservice just look here

Community
  • 1
  • 1
Alex Cio
  • 6,014
  • 5
  • 44
  • 74