Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > XML and SOAP

XML and SOAP
Thread Tools
Fresh-Faced Recruit
Join Date: Nov 2001
Location: Oregon or Alaska
Status: Offline
Reply With Quote
Feb 3, 2005, 04:18 AM
 
I'm trying to access an object via SOAP, but am struggling with Apple's objective-c implementation. After lots of messing around, I thought I came up with something that should work.... yet it doesn't.

I'm trying to access Terraserver and use this method: http://terraserver-usa.com/TerraServ...ToNearestPlace -- also, here is the WSDL file.

My output looks like this:
Code:
<?xml.version="1.0".encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Body> <m:ConverLonLatPtToNearestPlace xmlns:m="http://localhost/TerraWebSite/"> <point xsi:type="m:LonLatPt"> <Lon xsi:type="xsd:double">-123.19995</Lon> <Lat xsi:type="xsd:double">44.02597</Lat> </point> </m:ConvertLonLatPtToNearestPlace> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
What's wrong???
(Last edited by Doktorfaust; Feb 3, 2005 at 12:57 PM. )
Die Menchen verhöhnen was sie nicht verstehen.
     
Professional Poster
Join Date: Oct 2001
Location: London
Status: Offline
Reply With Quote
Feb 3, 2005, 06:34 AM
 
Have you tried using WSMakeStubs on that WSDL?
You know it makes sense. ☼ ☼ ☼ Growl.
     
Professional Poster
Join Date: Oct 2001
Location: London
Status: Offline
Reply With Quote
Feb 3, 2005, 06:39 AM
 
Code:
Widebook:~ diggory$ /Developer/Tools/WSMakeStubs -x ObjC -name TerraStubs -url "http://terraserver-usa.com/TerraService2.asmx?WSDL"
Should get you what you need:

Code:
<snip> /*- * Method Name: ConvertLonLatPtToNearestPlace * Documentation: <no documentation> */ @implementation ConvertLonLatPtToNearestPlace - (void) setParameters:(CFTypeRef /* Complex type http://localhost/TerraWebSite/|ConvertLonLatPtToNearestPlace */) in_parameters { id _paramValues[] = { in_parameters, }; NSString* _paramNames[] = { @"parameters", }; [super setParameters:1 values: _paramValues names: _paramNames]; } - (id) resultValue { return [[super getResultDictionary] objectForKey: @"parameters"]; } - (WSMethodInvocationRef) genCreateInvocationRef { return [self createInvocationRef /*endpoint*/: @"http://terraserver-usa.com/TerraService2.asmx" methodName: @"ConvertLonLatPtToNearestPlace" protocol: (NSString*) kWSSOAP2001Protocol style: (NSString*) kWSSOAPStyleRPC soapAction: @"http://localhost/TerraWebSite/ConvertLonLatPtToNearestPlace" methodNamespace: NULL /* No Method Namespace specified */ ]; } @end; /* ConvertLonLatPtToNearestPlace */ <snip>
"The test form is only available for requests from the local machine." sounds worrying. What is the test form? and why are there so many references to localhost?
You know it makes sense. ☼ ☼ ☼ Growl.
     
Fresh-Faced Recruit
Join Date: Nov 2001
Location: Oregon or Alaska
Status: Offline
Reply With Quote
Feb 3, 2005, 12:35 PM
 
Originally posted by Diggory Laycock:
Have you tried using WSMakeStubs on that WSDL?
Yes, I've done it both with WSMakeStubs and manually, calling the C functions directly. WSMakeStubs required some modification to the output in order to make things run at all. In both cases I then I had to add a "metadata" key to the dictionary in order to set a ComplexType (for LatLonPt). I have both the more manual approach and the WSMakeStubs approach producing the same output I pasted above.

I need to figure out what's wrong the XML being sent that Terraserver will only give me back a default response: it defaults to lat=0, lon=0 and tells me I'm about 800 km off of the Ivory Coast. Clearly it's not understanding the coordinates I send it.

thanks,
DF
Die Menchen verhöhnen was sie nicht verstehen.
     
Fresh-Faced Recruit
Join Date: Nov 2001
Location: Oregon or Alaska
Status: Offline
Reply With Quote
Feb 3, 2005, 12:45 PM
 
Originally posted by Diggory Laycock:
"The test form is only available for requests from the local machine." sounds worrying. What is the test form? and why are there so many references to localhost?
Good question -- I tried a few things just now.

The "soapAction" action definitely needs to be specified exactly as is shown in the example. When I have
Code:
SOAPAction: "http://terraserver-usa.com/ConvertLonLatPtToNearestPlace"
the request fails with "in _parseFault". However, when I have it written as,
Code:
SOAPAction: "http://localhost/TerraWebSite/ConvertLonLatPtToNearestPlace"
The request goes through and I get a response -- though it's always for that default latitude and longitude.

I'm thinking it's a namespace problem -- probably related to the line:
Code:
<m:ConverLonLatPtToNearestPlace xmlns:m="http://localhost/TerraWebSite/">
Hmmmm.....
(Last edited by Doktorfaust; Feb 3, 2005 at 12:53 PM. )
Die Menchen verhöhnen was sie nicht verstehen.
     
Fresh-Faced Recruit
Join Date: Nov 2001
Location: Oregon or Alaska
Status: Offline
Reply With Quote
Feb 8, 2005, 12:47 AM
 
It turns out the problem is with Microsoft's TerraServer, not the request being made. They don't properly handle namespace aliases. So by removing the alias to "http://localhost/TerraWebSite/", (:m), everything worked fine.

Here's a tip though for anyone trying to debug something like this. You can directly send whatever information you want to a server simply by using telnet. So to send the packet I wanted to terraserver, I simply type
Code:
jearly$ telnet terraserver-usa.com 80
And then fire away with whatever request I wanted. In this case, something like
Code:
POST /TerraService2.asmx HTTP/1.1 Host: terraserver-usa.com Content-Type: text/xml; charset=utf-8 Content-Length: 457 SOAPAction: "http://localhost/TerraWebSite/ConvertLonLatPtToNearestPlace" <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <ConvertLonLatPtToNearestPlace xmlns:m="http://localhost/TerraWebSite/"> <point> <Lon>-120.0</Lon> <Lat>44.0</Lat> </point> </ConvertLonLatPtToNearestPlace> </soap:Body> </soap:Envelope>
TerraServer responds...
Die Menchen verhöhnen was sie nicht verstehen.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:08 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2