Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Issue with Web Service...

Status
Not open for further replies.

Neil Toulouse

Programmer
Mar 18, 2002
882
GB
Hi Guys!

I am playing around with some simple web service integration in VFP so took a simple 'free' example web service off the web to play with. I have coded it as such:

Code:
LOCAL oWebService, lcResult

oWebService = CREATEOBJECT("MSSOAP.SoapClient30")
oWebService.MSSoapInit("[URL unfurl="true"]http://www.webservicex.net/CurrencyConvertor.asmx?WSDL")[/URL]

lcResult = oWebService.ConversionRate("MXN","GBP")

RELEASE oWebService


The error received is on the 'lcResult...' line (after quite sometime):


Code:
OLE IDispatch exception code 0 from Connector: Connector:Host not found. HRESULT=0x800A1521 - Client:An unanticipated error occurred during the processing of this request. HRESULT=0x800A1521 - Client:Sending the Soap message failed or no recognizable response was received HRESULT=0x800A1521 - Client:Unspecified client error. HRESULT=0x800A1521..

The WSDL checks out OK on the web, so I guess I am implementing it wrong, or our network is stopping it for some reason.

Can anyone shed some light, or confirm it works?

TIA
Neil

I like work. It fascinates me. I can sit and look at it for hours...
 
Neil,

Not sure what's wrong with your code. However, have you considered using Intellisense to generate the code for you? You end up with a bit more code than in your example, but it always seems to work OK.

In summary, this is how you do it.

First, execute this line from the command window:

DO (_wizard) WITH "project",,"Web","IntelliSense"

When prompted to do so, enter the address of your WDSL (as per your example). Then click Done.

You can now open the Toolbox (from the Tools menu), drill down into "My XML Web Services", and drag the name of the service (probably something like Currency Converter) to a code editing window. That will generate all the setup code you need.

Finally, add the call to the ConversionRate method, as per your existing code. Intellisense will be available, so you will get help on the parameters if needed.

No doubt Olaf or Dan or someone else will give you a simpler solution to your question, in which case just ignore me.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Neil, since posting the above reply, I tried your code, and also tried the method I suggested. In both cases, I couldn't connect to the web service at all.

Are you sure you posted the correct URL to the WSDL? I tried pasting into a browser, but it just hanged when trying to connect.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Thanks for your response Mike!

Looks like I may have picked a dud example to play with. If you paste the URL into a browser it does appear but takes quit a while. I wonder if the call is timing out before the result is returned.

Hmm... Ok not to worry I will look at it again tomorrow and use a different example!

Neil

I like work. It fascinates me. I can sit and look at it for hours...
 
One of the biggest frustrations when you're working with web services is that the quality of your code doesn't mean beans when the other side isn't responding.
 
Mike,

I'm curious (and too lazy to actually check it out)... if you're telling someone to eventually open the toolbox *anyway* to use the newly-registered web service, why not also register it from the toolbox? Why the command-driven registration?

Is there a substantive difference, or just "the way it came out"?
 
Dan,

The main reason I suggested the code-based registration was that it was easier to explain in a forum posting: one line of code to paste into the command window rather than two or three separate steps in the task pane. Also, I've got an irrational prejudice against the task pane.

Actually, I should have gone a bit further. Rather than using the toolbox to generate the code, I should have suggested typing ws in the code editing window. The only reason I didn't was because I didn't think of it.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Thanks. Dislike of the task pane is something we share. :)

It just seemed odd to go there for one and not the other.
 
Just want to point out the Toolbox is NOT the TaskPane. You can register web services from the Toolbox, and it's a good way to do it, since the Toolbox gives you an easy way to drop the web service into your code.

Tamar
 
Dang. Thanks, Tamar.

I'm not a big fan of either, although for entirely different reasons.
 
Hi Mike

I have gone down the route of your example and still having problems! I can confirm the web service checks out fine in my browser.

I have registered the web service with intellisense as you suggested, and the code I am now using is:

Code:
LOCAL loUKLocation AS "XML Web Service"
* LOCAL loUKLocation AS "MSSOAP.SoapClient30"
* Do not remove or alter following line. It is used to support IntelliSense for your XML Web service.
*__VFPWSDef__: loUKLocation = [URL unfurl="true"]http://www.webservicex.com/uklocation.asmx?WSDL[/URL] , UKLocation , UKLocationSoap
LOCAL loException, lcErrorMsg, loWSHandler, lcResult
TRY
	loWSHandler = NEWOBJECT("WSHandler",IIF(VERSION(2)=0,"",HOME()+"FFC\")+"_ws3client.vcx")
	loUKLocation = loWSHandler.SetupClient("[URL unfurl="true"]http://www.webservicex.com/uklocation.asmx?WSDL",[/URL] "UKLocation", "UKLocationSoap")

	lcResult = loUKLocation.GetUKLocationByPostCode("B")

CATCH TO loException
	lcErrorMsg="Error: "+TRANSFORM(loException.Errorno)+" - "+loException.MESSAGE
	DO CASE
		CASE VARTYPE(loUKLocation)#"O"
			* Handle SOAP error connecting to web service
		CASE !EMPTY(loUKLocation.FaultCode)
			* Handle SOAP error calling method
			lcErrorMsg=lcErrorMsg+CHR(13)+loUKLocation.Detail
		OTHERWISE
			* Handle other error
	ENDCASE
	* Use for debugging purposes
	MESSAGEBOX(lcErrorMsg)
FINALLY
ENDTRY

RELEASE loWSHandler
RELEASE loUKLocation

Again it falls over at the 'lcResult' line with this error:

Code:
Error: 1429 - OLE IDispatch exception code 0 from Connector: Connector:Host not found. HRESULT=0x800A1521 - Client:An unanticipated error occurred during the processing of this request. HRESULT=0x800A1521 - Client:Sending the Soap message failed or no recognizable response was received HRESULT=0x800A1521 - Client:Unspecified client error. HRESULT=0x800A1521..
Connector:Host not found. HRESULT=0x800A1521 - Client:An unanticipated error occurred during the processing of this request. HRESULT=0x800A1521 - Client:Sending the Soap message failed or no recognizable response was received HRESULT=0x800A1521 - Client:Unspecified client error. HRESULT=0x800A1521

Have I done something wrong?

Thanks
Neil

I like work. It fascinates me. I can sit and look at it for hours...
 
Neil,

The problem must be in your network, or your SOAP components, or your security settings, or something else in your environment.

I just ran your latest code, and it worked perfectly. I even managed to convert the XML in lcResult to a cursor.

So, your code is OK. Can you try running it in a different environment (at home, for example)?

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Hi Mike!

That is what I feared - I would imagine (knowing this place) it will be a network issue!

Anyways, many thanks for the help on this. I will have to play at home instead!

Neil



I like work. It fascinates me. I can sit and look at it for hours...
 
Just to end this thread, I have just confirmed it was an issue with our 'standard' proxy. I have been given the IP for another proxy on the network and it works!

I had to add the line:

Code:
loUKLocation.ConnectorProperty("ProxyServer")="111.222.333.444:80"

(with appropriate IP address and port set).

Thanks for all the help on is. Appreciated.

I like work. It fascinates me. I can sit and look at it for hours...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top