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

blue44Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
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

blue44Author Commented:
Good try but same result:
Web service operation test1 with parameters {QueryString={00006-0464-05},Type={NDC},Token=YourTokenHere} cannot be found.
käµfm³d 👽Commented:
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?
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

Brijesh ChauhanStaff IT EngineerCommented:
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

blue44Author Commented:
@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>

Brijesh ChauhanStaff IT EngineerCommented:
There is a SOAPACTION Defined in the WSDL and I was passing it as blank, usually it is.. but I have added it now below to CFHTTPPARAM, try the code below, I test it and it works...

<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://YourWDSLHere.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="http://YourWDSLHere.com/webservice/2008/Query"> 
    <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


RESULTS

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><QueryResponse xmlns="http://YourWDSLHere.com/webservice/2008"><QueryResult><WebServiceResult><Type>NDC</Type><Key>0006-0464-01</Key><ResultSet><Pair><Name>NDCCode</Name><Value>0006-0464-01</Value></Pair><Pair><Name>TradeName</Name><Value>EMEND CAPSULES</Value></Pair><Pair><Name>FirmName</Name><Value>MERCK AND CO INC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>0006-0464-05</Key><ResultSet><Pair><Name>NDCCode</Name><Value>0006-0464-05</Value></Pair><Pair><Name>TradeName</Name><Value>EMEND CAPSULES</Value></Pair><Pair><Name>FirmName</Name><Value>MERCK AND CO INC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>0006-0464-10</Key><ResultSet><Pair><Name>NDCCode</Name><Value>0006-0464-10</Value></Pair><Pair><Name>TradeName</Name><Value>EMEND CAPSULES</Value></Pair><Pair><Name>FirmName</Name><Value>MERCK AND CO INC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>49288-0464-5</Key><ResultSet><Pair><Name>NDCCode</Name><Value>49288-0464-5</Value></Pair><Pair><Name>TradeName</Name><Value>SPONDYLOCLADIUM INJECTION SOLUTION</Value></Pair><Pair><Name>FirmName</Name><Value>ANTIGEN LABORATORIES INC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>53746-464-01</Key><ResultSet><Pair><Name>NDCCode</Name><Value>53746-464-01</Value></Pair><Pair><Name>TradeName</Name><Value>IBUPROFEN TABLETS</Value></Pair><Pair><Name>FirmName</Name><Value>AMNEAL PHARMACEUTICALS NY LLC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>53746-464-05</Key><ResultSet><Pair><Name>NDCCode</Name><Value>53746-464-05</Value></Pair><Pair><Name>TradeName</Name><Value>IBUPROFEN TABLETS</Value></Pair><Pair><Name>FirmName</Name><Value>AMNEAL PHARMACEUTICALS NY LLC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>53746-464-30</Key><ResultSet><Pair><Name>NDCCode</Name><Value>53746-464-30</Value></Pair><Pair><Name>TradeName</Name><Value>IBUPROFEN TABLETS</Value></Pair><Pair><Name>FirmName</Name><Value>AMNEAL PHARMACEUTICALS NY LLC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>53746-464-60</Key><ResultSet><Pair><Name>NDCCode</Name><Value>53746-464-60</Value></Pair><Pair><Name>TradeName</Name><Value>IBUPROFEN TABLETS</Value></Pair><Pair><Name>FirmName</Name><Value>AMNEAL PHARMACEUTICALS NY LLC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>53746-464-90</Key><ResultSet><Pair><Name>NDCCode</Name><Value>53746-464-90</Value></Pair><Pair><Name>TradeName</Name><Value>IBUPROFEN TABLETS</Value></Pair><Pair><Name>FirmName</Name><Value>AMNEAL PHARMACEUTICALS NY LLC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>62794-464-01</Key><ResultSet><Pair><Name>NDCCode</Name><Value>62794-464-01</Value></Pair><Pair><Name>TradeName</Name><Value>MAXZIDE .25 MG TABLETS</Value></Pair><Pair><Name>FirmName</Name><Value>MYLAN BERTEK PHARMACEUTICALS INC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>62794-464-05</Key><ResultSet><Pair><Name>NDCCode</Name><Value>62794-464-05</Value></Pair><Pair><Name>TradeName</Name><Value>MAXZIDE .25 MG TABLETS</Value></Pair><Pair><Name>FirmName</Name><Value>MYLAN BERTEK PHARMACEUTICALS INC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>62794-464-88</Key><ResultSet><Pair><Name>NDCCode</Name><Value>62794-464-88</Value></Pair><Pair><Name>TradeName</Name><Value>MAXZIDE .25 MG TABLETS</Value></Pair><Pair><Name>FirmName</Name><Value>MYLAN BERTEK PHARMACEUTICALS INC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>63739-464-05</Key><ResultSet><Pair><Name>NDCCode</Name><Value>63739-464-05</Value></Pair><Pair><Name>TradeName</Name><Value>FUROSEMIDE INJECTION</Value></Pair><Pair><Name>FirmName</Name><Value>MCKESSON PACKAGING SERVICES BUSINESS UNIT MCKESSON CORP</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>0078-0464-61</Key><ResultSet><Pair><Name>NDCCode</Name><Value>0078-0464-61</Value></Pair><Pair><Name>TradeName</Name><Value>AREDIA FOR INJECTION</Value></Pair><Pair><Name>FirmName</Name><Value>NOVARTIS PHARMACEUTICALS CORP</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>0378-0464-01</Key><ResultSet><Pair><Name>NDCCode</Name><Value>0378-0464-01</Value></Pair><Pair><Name>TradeName</Name><Value>MAXZIDE TABLETS</Value></Pair><Pair><Name>FirmName</Name><Value>MYLAN PHARMACEUTICALS INC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>0456-0464-01</Key><ResultSet><Pair><Name>NDCCode</Name><Value>0456-0464-01</Value></Pair><Pair><Name>TradeName</Name><Value>ARMOUR THYROID TABLETS</Value></Pair><Pair><Name>FirmName</Name><Value>FOREST PHARMACEUTICALS INC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>0472-0464-01</Key><ResultSet><Pair><Name>NDCCode</Name><Value>0472-0464-01</Value></Pair><Pair><Name>TradeName</Name><Value>BENZOYL PEROXIDE PADS</Value></Pair><Pair><Name>FirmName</Name><Value>ACTAVIS MID ATLANTIC LLC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>0472-0464-30</Key><ResultSet><Pair><Name>NDCCode</Name><Value>0472-0464-30</Value></Pair><Pair><Name>TradeName</Name><Value>BENZOYL PEROXIDE PADS</Value></Pair><Pair><Name>FirmName</Name><Value>ACTAVIS MID ATLANTIC LLC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>0472-0464-60</Key><ResultSet><Pair><Name>NDCCode</Name><Value>0472-0464-60</Value></Pair><Pair><Name>TradeName</Name><Value>BENZOYL PEROXIDE PADS</Value></Pair><Pair><Name>FirmName</Name><Value>ACTAVIS MID ATLANTIC LLC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>10267-0464-0</Key><ResultSet><Pair><Name>NDCCode</Name><Value>10267-0464-0</Value></Pair><Pair><Name>TradeName</Name><Value>FEROTRINSIC CAPSULES</Value></Pair><Pair><Name>FirmName</Name><Value>CONTRACT PHARMACAL CORP</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>10267-0464-1</Key><ResultSet><Pair><Name>NDCCode</Name><Value>10267-0464-1</Value></Pair><Pair><Name>TradeName</Name><Value>FEROTRINSIC CAPSULES</Value></Pair><Pair><Name>FirmName</Name><Value>CONTRACT PHARMACAL CORP</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>10267-0464-4</Key><ResultSet><Pair><Name>NDCCode</Name><Value>10267-0464-4</Value></Pair><Pair><Name>TradeName</Name><Value>FEROTRINSIC CAPSULES</Value></Pair><Pair><Name>FirmName</Name><Value>CONTRACT PHARMACAL CORP</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>13411-464-04</Key><ResultSet><Pair><Name>NDCCode</Name><Value>13411-464-04</Value></Pair><Pair><Name>TradeName</Name><Value>ERYTHROCIN STEARATE TABLETS</Value></Pair><Pair><Name>FirmName</Name><Value>ADVANCED PHARMACEUTICAL SERVICES INC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>14049-464-34</Key><ResultSet><Pair><Name>NDCCode</Name><Value>14049-464-34</Value></Pair><Pair><Name>TradeName</Name><Value>NEOMYCIN AND POLYMYXIN B SULFATES AND BACITRACIN OPH OINTMENT</Value></Pair><Pair><Name>FirmName</Name><Value>RX VETERINARY PRODUCTS</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>21695-464-07</Key><ResultSet><Pair><Name>NDCCode</Name><Value>21695-464-07</Value></Pair><Pair><Name>TradeName</Name><Value>LEVAQUIN TABLETS</Value></Pair><Pair><Name>FirmName</Name><Value>REBEL DISTRIBUTORS CORP</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>33261-464-01</Key><ResultSet><Pair><Name>NDCCode</Name><Value>33261-464-01</Value></Pair><Pair><Name>TradeName</Name><Value>AMOXICILLIN CLAVULANATE POTASSIUM SUSPENSION</Value></Pair><Pair><Name>FirmName</Name><Value>AIDAREX PHARMACUTICALS LLC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>33358-464-30</Key><ResultSet><Pair><Name>NDCCode</Name><Value>33358-464-30</Value></Pair><Pair><Name>TradeName</Name><Value>BENAZEPRIL HYDROCHLORIDE AND HYDROCHLOROTHIAZIDE TABLETS</Value></Pair><Pair><Name>FirmName</Name><Value>CORE PHARMACEUTICALS INC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>43353-464-32</Key><ResultSet><Pair><Name>NDCCode</Name><Value>43353-464-32</Value></Pair><Pair><Name>TradeName</Name><Value>RISPERIDONE TABLETS</Value></Pair><Pair><Name>FirmName</Name><Value>DBA PREPAK SYSTEMS INC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>49288-0464-1</Key><ResultSet><Pair><Name>NDCCode</Name><Value>49288-0464-1</Value></Pair><Pair><Name>TradeName</Name><Value>SPONDYLOCLADIUM INJECTION SOLUTION</Value></Pair><Pair><Name>FirmName</Name><Value>ANTIGEN LABORATORIES INC</Value></Pair></ResultSet></WebServiceResult><WebServiceResult><Type>NDC</Type><Key>49288-0464-2</Key><ResultSet><Pair><Name>NDCCode</Name><Value>49288-0464-2</Value></Pair><Pair><Name>TradeName</Name><Value>SPONDYLOCLADIUM INJECTION SOLUTION</Value></Pair><Pair><Name>FirmName</Name><Value>ANTIGEN LABORATORIES INC</Value></Pair></ResultSet></WebServiceResult></QueryResult></QueryResponse></soap:Body></soap:Envelope>

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
blue44Author Commented:
@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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ColdFusion Language

From novice to tech pro — start learning today.