Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Coldfusion invoke web service

Participant ,
Sep 27, 2011 Sep 27, 2011

I am trying to invoke a web service and I'm getting an error.

Error 401 Unauthorized.  Unable to read WSDL from URL: http://servername/generation/bj/TestCalculation.wsdl.  An exception occurred while invoking an event handler method from Application.cfc. The method name is: onRequest.

I can put the URL in the browser and it will pull up the WSDL. I can call this from a flex program and it will work fine.  I don't know much about Flex and I'm just learning it so I wanted to see if I could get it to work with ColdFusion.  

Here is the CFC I created:

    <cffunction name="myCalcFunction" access="remote" returntype="any">

            <cfinvoke

     webservice="http://servername/generation/bj/TestCalculation.wsdl"

     method="TestCalculation"

     returnvariable="response">

     <cfinvokeargument name="number1" value="#arguments.number1#"/>

     <cfinvokeargument name="number2" value="#arguments.number2#"/>

   </cfinvoke>

  <cfreturn response>

</cffunction>

Can anyone point me in the right direction of what I can do?

thanks for the support.

BJ

TOPICS
Advanced techniques
12.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Participant , Oct 06, 2011 Oct 06, 2011

Yes,  I finally found out it is a coldfusion 9.1 problem.    I uninstalled CF9.1 and installed CF8 and CF9.0 on my local machine.  I ran the web service code in both and it worked in both.  I then updated my CF9.0 to CF9.1.  I ran it again and it will give me the error.  This is running the same code with the same application.cfc.   Now I need to get Adobe to fix the problem.

BKBK, Adam, Dan and Owain,

   Thanks for the help on this.

BJ

Translate
Participant ,
Oct 03, 2011 Oct 03, 2011

BKBK,

   THe WSDL is the XML file that has all the information needed to call the service.  The WSDL is called TestCalculation.wsdl that was generated from some middleware software to run the service.  The method in the WSDL file is TestCalculation. 

The WSDL file is in the same directory as the programs.  So on the dev machine the WSDL is with the CFM and CFC file and on my local machine I have the WSDL file there.  So it just depends on which one I call.  The actual service is on a totally different machine that my local machine and the dev machine should get to and the WSDL has that path.  Again, that path works since I can get it to work on my local machine.

I hope this clears up some.

thanks,

BJ

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 03, 2011 Oct 03, 2011

BJ - CF wrote:

   THe WSDL is the XML file that has all the information needed to call the service.  The WSDL is called TestCalculation.wsdl that was generated from some middleware software to run the service.  The method in the WSDL file is TestCalculation. 

The WSDL file is in the same directory as the programs.  So on the dev machine the WSDL is with the CFM and CFC file and on my local machine I have the WSDL file there.  So it just depends on which one I call.  The actual service is on a totally different machine that my local machine and the dev machine should get to and the WSDL has that path.  Again, that path works since I can get it to work on my local machine.

I hope this clears up some.

This only raises the confusion to the n-th degree. In web service terminology, WSDL is reserved as a synonym of the web service itself. In other words, the WSDL is the web service.

However, you seem to use the WSDL as some (XML) means to call the web service. The WSDL should not have "all the information needed to call the service"; the WSDL should be the web service. Unless, of course, you are making a call to a web service to call another web service. Is that so?

So on the dev machine the WSDL is with the CFM and CFC file...

This seems to say the WSDL(hence the web service) is on the dev machine.

... on my local machine I have the WSDL file there.

This seems to say the WSDL(hence the web service) is on your local machine.

...The actual service is on a totally different machine

This seems to say the web service is on a third machine.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 04, 2011 Oct 04, 2011

BKBK -

   I'm new to SOA/web services so maybe I'm not saying it right but I don't think we are on the same page.  In the defintion, the WSDL is just an XML based file used to describe the functionality offered by a web service. I don't need to know anything about the service except the inputs and outputs and the URL to call the WSDL.

I created a service to calculate two numbers and return the result using a software called NextAxiom that my company has.  This service is not sitting on our web server but on one of our machines on our network.  See below for the WSDL file I have listed.  I was just trying to use some of the standards that I read about and was using a CFC to invoke the web service so any CFM program would be able to call the CFC and not put it in the CFM program.  But for now I can just put in the invoke tag in my CFM code:

    

  <cfinvoke

            webservice="http://localhost/TestCalculation.wsdl?wsdl"

            method="TestCalculation" refreshwsdl="true"

            returnvariable="response">

            <cfinvokeargument name="number1" value="5"/>

            <cfinvokeargument name="number2" value="6"/>

                              </cfinvoke>

<cfdump var="#response#">

Doing this, I can run the CFM program and it will come back with 11.  This works great on my local CF server.  When I try and run it on my dev machine I get the 401 unauthorized error. (yes I change the path of the wsdl to the path that the WSDL is on my dev web server.)

So it looks like some type of permission problem.  My question is where do I look?

thanks for all replys,

BJ

Here is my WSDL file.  If you notice the bold line at the bottom, that is the server where my service is.

<!--

Automatically generated 09/23/2011 by Hyperservice Business Platform, NextAxiom Technology, Inc.

-->

<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"xmlns:tns="http://www.nextaxiom.com/soapservice/TrainingBJ.TestCalc.TestCalculation/wsdl" xmlns:xsd="http://www.w3.org/2001/XMLSchema"xmlns:xsd1="http://www.nextaxiom.com/soapservice/xsd1" name="TrainingBJ.TestCalc.TestCalculation"targetNamespace="http://www.nextaxiom.com/soapservice/TrainingBJ.TestCalc.TestCalculation/wsdl">

<types>

<schema xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"targetNamespace="http://www.nextaxiom.com/soapservice/xsd1">

<element name="TestCalculation">

<complexType>

<sequence>

<element name="number1" type="long"/>

<element name="number2" type="long"/>

</sequence>

</complexType>

</element>

<element name="TestCalculationResult">

<complexType>

<sequence>

<element name="result" type="long"/>

</sequence>

</complexType>

</element>

</schema>

</types>

<message name="TestCalculationRequest">

<part element="xsd1:TestCalculation" name="TestCalculation"/>

</message>

<message name="TestCalculationResponse">

<part element="xsd1:TestCalculationResult" name="TestCalculationResult"/>

</message>

<portType name="TrainingBJ.TestCalc.TestCalculationSoapPort">

<operation name="TestCalculation">

<input message="tns:TestCalculationRequest"/>

<output message="tns:TestCalculationResponse"/>

</operation>

</portType>

<binding name="TrainingBJ.TestCalc.TestCalculationSoapBinding" type="tns:TrainingBJ.TestCalc.TestCalculationSoapPort">

<soap:binding xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

<operation name="TestCalculation">

<soap:operation xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" soapAction="urn:doc?in=TestCalculation?out=TestCalculationResult?path=TrainingBJ.TestCalc.TestCalculation"/>

<input>

<soap:body use="literal"/>

</input>

<output>

<soap:body use="literal"/>

</output>

</operation>

</binding>

<service name="TrainingBJ.TestCalc.TestCalculation">

<port binding="tns:TrainingBJ.TestCalc.TestCalculationSoapBinding" name="TrainingBJ.TestCalc.TestCalculationPort">

</port>

</service>

</definitions>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 04, 2011 Oct 04, 2011

OK, I understand. One aspect that could differ between your local and dev machines, and that could require authorization, is a proxy. So, does a proxy (or other IP filter) allow your local machine but forbid your dev server?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 05, 2011 Oct 05, 2011

BKBK,

  This one I'm not sure what you are asking.  Can you give me more details.

thanks,

BJ

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 05, 2011 Oct 05, 2011

Ask your System Administrator whether your network is behind a proxy server.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 06, 2011 Oct 06, 2011

I think I found the problem but again I don't know how to solve it.  The program is working on my localhost but not on our dev server.  I checked and we aren't behind a proxy server.  The only difference between my localhost and my dev server is the dev server was on CF9.1 and my local was just at CF9.0.  I updated my local to 9.1 and now it is not working on my localhost and I'm getting the same error I was getting on my dev machine.  Something changed in 9.1. 

I want to try and go back to 9.0 on my dev and see if my program runs.  Is there anyway to back out the change or do I uninstall and reinstall 9?

Anyone else have problems on CF 9.1 like this.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 06, 2011 Oct 06, 2011

Yes,  I finally found out it is a coldfusion 9.1 problem.    I uninstalled CF9.1 and installed CF8 and CF9.0 on my local machine.  I ran the web service code in both and it worked in both.  I then updated my CF9.0 to CF9.1.  I ran it again and it will give me the error.  This is running the same code with the same application.cfc.   Now I need to get Adobe to fix the problem.

BKBK, Adam, Dan and Owain,

   Thanks for the help on this.

BJ

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 07, 2011 Oct 07, 2011
LATEST

BJ - CF wrote:

Yes,  I finally found out it is a coldfusion 9.1 problem.    I uninstalled CF9.1 and installed CF8 and CF9.0 on my local machine.  I ran the web service code in both and it worked in both.  I then updated my CF9.0 to CF9.1.  I ran it again and it will give me the error.  This is running the same code with the same application.cfc.   Now I need to get Adobe to fix the problem.

BKBK, Adam, Dan and Owain,

   Thanks for the help on this.

BJ

BJ - CF,

Thank you, too, for sharing 2 things with us. Your debugging skills and, more importantly, virtue of patience.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 03, 2011 Oct 03, 2011

On the dev server I put the CFC in the browser and it came back and asked for the RDS password. Adam is this what you meant when you said to call the method via the browser?  Here is the info it put out after I entered the password:

Nope, not quite.  I mean do this:

http://domain/path/to/webservice.cfc?wsdl&method=foo&arg1=bar[&etc...]

How there's a problem here:

hierarchy:WEB-INF.cftags.component
      Generation.BJ.CalculateTwoNumbers
path:E:\Tristate\Generation\BJ\CalculateTwoNumbers.cfc
serializable:Yes
properties:
methods:myCalcFunction

* - private method

myCalcFunction
public any myCalcFunction ( )

Output:

To call a method as a web service it must be access=remote.  There are no remote methods in there.

--
Adam

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 03, 2011 Oct 03, 2011

Adam,

   I ran this URL: http://servername/generation/bj/TestCalculation.wsdl?wsdl?method=TestCalculation&arg1=4&arg2=5 on the dev machine and it came back with the XML file.

  Also, I did have remote on the cfinvoke, I think I grab the wrong one when BKBK said to try it with public and that is the one that was listed.

thanks,

BJ

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources