Link to home
Start Free TrialLog in
Avatar of blue44
blue44Flag for United States of America

asked on

Consuming a .NET web service from ColdFusion

Hi,

I"m trying to consume a .NET web service and keep getting the following error:

Web service operation test1 with parameters {QUERYSTRING={00006-0464-05},TYPE={NDC},TOKEN={YourTokenHere}} cannot be found.

I've tried many different combinations but just can't crack it.  Any help is greatly appreciated.

Thanks!
<cfscript>
&#9;myrequest = structNew();
&#9;myrequest.Type='NDC';
&#9;myrequest.QueryString='00006-0464-05';
&#9;myrequest.Token ='YourTokenHere';
</cfscript>

<cfinvoke webservice="http://www.YourWSDLHere.com/wspHVLookup.asmx?WSDL" argumentCollection="#myrequest#" returnvariable="result" method="Query">

<cfdump var="#result#">

Open in new window

Avatar of kaufmed
kaufmed
Flag of United States of America image

What about this?
<cfinvoke
   method="test1"
   returnvariable="result"
   webservice="http://www.YourWSDLHere.com/wspHVLookup.asmx?WSDL">

   <cfinvokeargument name="QueryString" value="00006-0464-05">
   <cfinvokeargument name="Type" value="NDC">
   <cfinvokeargument name="Token" value="YourTokenHere">
</cfinvoke>

<cfset parsedResult = XmlParse(result)>

<cfdump var="#parsedResult#">

Open in new window

Avatar of blue44

ASKER

Good try but same result:
Web service operation test1 with parameters {QueryString={00006-0464-05},Type={NDC},Token=YourTokenHere} cannot be found.
I'm not the most talented at reading WSDL files, but I don't see anything mentioned in that WSDL about a function called "test1". Which function are you trying to call?
Use SOAP..

<cfsavecontent variable="soap"> 
<?xml version="1.0" encoding="UTF-8" standalone="no"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://YourWSDLHere.com/webservice/2008" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
<SOAP-ENV:Body>
<tns:Query xmlns:tns="http://YourWDSLHere.com/webservice/2008">
<tns:Type>NDC</tns:Type>
<tns:QueryString>00006-0464-05</tns:QueryString>
<tns:Token>YourTokenHere</tns:Token>
</tns:Query>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
</cfsavecontent>

<cfhttp url="http://www.YourWDSLHere.com/wspHVLookup.asmx" method="post">
&#9; <cfhttpparam type="header" name="content-type" value="text/xml"> 
    <cfhttpparam type="header" name="SOAPAction" value=""> 
    <cfhttpparam type="header" name="content-length" value="#len(soap)#"> 
    <cfhttpparam type="header" name="charset" value="utf-8"> 
    <cfhttpparam type="xml" name="message" value="#trim(soap)#">  
</cfhttp>

<cfdump var="#cfhttp.FileContent#">

Open in new window

Avatar of blue44

ASKER

@kaufmed: That was just a typo, but good catch :-) I'm trying to call the Query function and I still get the same error.

@brijeshchauhan: Thanks so much...I really think this is how I have to proceed...unfortunate I can't utilize cfinvoke.  I tried your code and got a new error:

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>Server did not recognize the value of HTTP Header SOAPAction: .</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope>

ASKER CERTIFIED SOLUTION
Avatar of Brijesh Chauhan
Brijesh Chauhan
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of blue44

ASKER

@brijeshchauhan: Perfect, it worked!! You are indeed a MASTER!! My next challenge it trying to parse this SOAP response into a CF object (i.e., array, query, struct, etc).  I will post a second question regarding this and it would be great if you could respond to it.