|
UsageInstructions
Instructions on how to use the generated code from WSDL2ObjC
Featured First stepsGenerating code out of the WSDL fileOnce you obtain WSDL2ObjC, code generation is pretty simple.
Source code files will be added to the output directory you've specified. Including the generated source filesYou can add the output files to your project or create a web service framework from them.
If you are building an iPhone project also perform the following:
Using the generated codeYou can use a given web service as follows: #import "MyWebService.h"
MyWebServiceBinding *binding = [MyWebService MyWebServiceBinding];
binding.logXMLInOut = YES;
ns1_MyOperationRequest *request = [[ns1_MyOperationRequest new] autorelease];
request.attribute = @"attributeValue";
request.element = [[ns1_MyElement new] autorelease];
request.element.value = @"elementValue"];
MyWebServiceBindingResponse *response = [binding myOperationUsingParameters:request];
NSArray *responseHeaders = response.headers;
NSArray *responseBodyParts = response.bodyParts;
for(id header in responseHeaders) {
if([header isKindOfClass:[ns2_MyHeaderResponse class]]) {
ns2_MyHeaderResponse *headerResponse = (ns2_MyHeaderResponse*)header;
// ... Handle ns2_MyHeaderResponse ...
}
}
for(id bodyPart in responseBodyParts) {
if([bodyPart isKindOfClass:[ns2_MyBodyResponse class]]) {
ns2_MyBodyResponse *body = (ns2_MyBodyResponse*)bodyPart;
// ... Handle ns2_MyBodyResponse ...
}
}ExampleAssume the following:
- (IBAction)pressedRequestButton:(id)sender {
FriendsBinding *bFriends = [[FriendsService FriendsBinding] retain];
bFriends.logXMLInOut = YES;
bFriends.authUsername = u.text;
bFriends.authPassword = p.text;
types_getFavoriteColorRequestType *cRequest = [[types_getFavoriteColorRequestType new] autorelease];
cRequest.friend = @"Johnny";
[bFriends getFavoriteColorAsyncUsingRequest:cRequest delegate:self];
}
- (void) operation:(FriendsBindingOperation *)operation completedWithResponse:(FriendsBindingResponse *)response
{
NSArray *responseHeaders = response.headers;
NSArray *responseBodyParts = response.bodyParts;
for(id header in responseHeaders) {
// here do what you want with the headers, if there's anything of value in them
}
for(id bodyPart in responseBodyParts) {
/****
* SOAP Fault Error
****/
if ([bodyPart isKindOfClass:[SOAPFault class]]) {
// You can get the error like this:
tV.text = ((SOAPFault *)bodyPart).simpleFaultString;
continue;
}
/****
* Get Favorite Color
****/
if([bodyPart isKindOfClass:[types_getFavoriteColorResponseType class]]) {
types_getFavoriteColorResponseType *body = (types_getFavoriteColorResponseType*)bodyPart;
// Now you can extract the color from the response
q.text = body.color;
continue;
}
// ...
}Advanced OptionsThe given example above covers basic authentication, as implemented in versions 0.6 and 0.7-pre1. The code in trunk has changed to support some more advanced security options, including advanced authentication and SOAP Security. NOTEIf a WSDL has defined a string type that has attributes, then wsdl2objc will map it to a generic NSObject with a property called "content" which will hold the actual string. So if you want to use the string, you have to call object.content. If you want its attributes, they're also properties of the object. The short reason for this is that Cocoa makes it very hard to subclass NSStrings. |
Awesome I am going to be trying this tonight! This is just what I have been waiting for!
Code generated using this project does not compile properly on the iPhone because NSCalendarDate is deprecated and does not exist in the SDK. The SDK docs state: For calendrical calculations, you should use suitable combinations of NSCalendar, NSDate, and NSDateComponents, as described in Calendars in Dates and Times Programming Topics for Cocoa.
Could you please add some more source code because some parameters are not clear to me.. :o( What is eg. MyWebServiceBindingResponse? ?
Please provide a complete example with all files. It can save the user so many hassles trying out the program.
Tobias
i got an error for including CFNetwork.framework, compiler suggested i use CoreServices? instead and it worked
NSCalendarDate is deprecated so it should be removed from the codebase and replaced with NSCalendar, NSDate and NSDateComponents.
I checked-out a read-only copy of the source tree and I'm trying to make the fix. What are .template files?
Note that it is "-I/usr/include/libxml2" with an "I" and not an "l". I would advice folks to copy-n-paste. If you still get an error linking libxml add "/usr/include/libxml2" to "Header Search Paths" in the build config of the Xcode project
I don't see CFNetwork.framework under frameworks.
I got the files generated to be included in my project and could build it. But I'm not clear how to use it. Can you please add a bit more code so that it becomes clear.
Guys, anyone have any progress to report on the NSDateCalendar issue?
I am getting an error " Assertion failure" on this line of the generated code.
NSAssert(doc != NULL, @"Errors while parsing returned XML");
My webservice works with other programs and through a standard WSDL web service test progam.
response.bodyParts; is a 0 length NSArray after the call.
Thanks.
This is the error I am getting on the server com.sun.xml.ws.server.UnsupportedMediaException?: Request doesnt have a Content-Type
Ok, I found 2 things that I had to modify with the generated code in order for this to work with JAX-WS.
1. Add Content-Type to the HTTP Header
2. My return element from JAX-WS was named "return" in the XML. I know its a reserved word in Java and C, but it is automatically created that way. WSDL2ObjC named the instance variable to "return_" in order to avoid a compilation error. Unfortunately, it was also looking for "return_" in the deserialization method, which fails becuase the real element name is "return".
Thanks for the head start on SOAP calls! I hope this helps out some others trying to do the same thing with JAX-WS web services.
Dave
Does someone wrote a patch to handle the NSCalendarDate issues? With the latest iPhone SDK there is no more NSCalendarDate…
Did somebody already manage to successfully use this code? Could someone provide a fully functional example?
Thanks,
I'm pretty sure the product owner got it to work for what he needed it to do and left. Which is cool.
It's open source, though, so patches are undoubtedly welcome. :)
Can anyone say why this is an improvement over using Apple's own WSMakeStubs? Currently this project is broken (on the iPhone) because of the unresolved NSCalendarDate problem
Because you can fix this one where it's broken and you can't fix Apple's where it's broken.
That's pretty much it.
Anyway, if it doesn't do what you need it to do: don't use it. I certainly don't!
I've fixed the code so that it now works on the iPhone and supports SOAP exception handling. I'd like to join the project so I can upload the fixes, but I can't find a "mailto" link for the project owner to send a join request. Am I missing something obvious?
I have uploaded the iPhone changes, however I have not tested how the generated code works on a Mac (I don't have a suitable test application or the time to write one). So for now the code is on a branch. I hope some kind soul will have the time and incentive to merge these changes back into the trunk at some point as they contain lots of useful stuff in addition to the iPhone changes. I would think that it should work "out of the box" as the iPhone API is a cut-down version of the MacOS API, but no guarantees.
Why not use async NSURLConnections? Those are available in both Mac & iPhone and would give a nice delegation method to the calls so they can be cancelled and don't require alot of thread headaches to deal with calls that may take a while on a slow network.
I certainly can't speak to the actual reasons for this project, but. The last time I tried it, NSURLConnection couldn't do NTLM authentication. You had to drop down to the CFNetwork stuff for that. I haven't tried it since 10.5.6 so it might work in 10.5.7, but I doubt it.
That was pretty much a deal-breaker for me and NSURLConnection.
Nevermind. It looks like the current code uses NSURLConnection. So obviously, that wasn't it.
Ok. So the new code doesn't use NCURLConnection (searched to make sure). It would be great if this was async..
On the instruction:
3. Add "-I/usr/include/libxml2" to the Other C Flags property
In Xcode 3.1.3, put /usr/include/libxml2 in the "Header Search Paths" setting in the "Search Paths" section (no need to check the "recursive" box).
Any issue of using /usr/include/libxml2 for Header Search Paths (relative to root) vs the same, but relative to the iPhone 3.0 SDK folder?
(btw...the timestamps appear newer on the iPhone copy)
Is the header search paths entry in addition to OR instead of the Other C Flags property, which was in 3.1.3 Pre Release, but no longer in the final 3.1.3 release.
Can someone give an example program with an example service to show how to pull out the data from the response? I am new to objc and having problems following the flow of the generated code to get to the return data.
Thank you for this code it's working great!
But the example code in the top of this page code be improved upon.
A real world example is preferred instead of MyWebserviceblabla? and the prefix ns1 doesn't really make things easier.
I'm having some trouble getting the generated code to work without memory leaks on iPhone.
I'm using the async methods. Can that cause the trouble I'm having?
I cannot find the Other C Flags property. in one of the posts it is mentioned that you need to create a User Property for that. So what should be the Property name "Other_C_Flags" = "/usr/include/libxml2"?
Other C Flags is now called Header Search Paths (under Search Paths) in latest pre-Snow Leopard xcode. Omit the -I prefix; i.e. /usr/include/libxml2/.
This fixes all compiler errors but leaves several linker errors that I'm still researching. For example, two warnings: no "-nsPrefix" method found, and 7 linker errors. I'm still searching for how to fix those.
The howto page really needs an update. Really.
@bradjcox the 'no -nsPrefix' probably is a problem with the parsing of the WSDL. Are you using the 0.5_iphone branch or the trunk?
XCode 3.1 doesn't have an "other C flags" setting, any ideas?
@senaimkon see @bradjcox's comment above.
Thanks Hasseily and bradjcox.
I have a WSDL file that generates fine using the Nov build. The June and latest build, including the latest source, crashes with a bad_exec error after spewing a bunch of these:
2009-09-08 13:18:25.579 WSDL2ObjC[3228:6a07] STS TemplateEngine? encountered ERROR in line 1 Placeholder 'part.element.type.classNameWithPtr' is undefined. Skipping placeholder 'part.element.type.classNameWithPtr' to continue. 2009-09-08 13:18:25.582 WSDL2ObjC[3228:6a07] errors have ocurred while expanding placeholders in string 2009-09-08 13:18:25.583 WSDL2ObjC[3228:6a07] errors have ocurred while expanding placeholders in string using dictionary: {
} 2009-09-08 13:18:25.583 WSDL2ObjC[3228:6a07] using template: ( ) 2009-09-08 13:18:25.585 WSDL2ObjC[3228:6a07] typeI'm on 10.6.
Any ideas?
Thanks for the help!
Ty
Re comment on wanting better example code: Still not a complete application, but there is a larger and perhaps more helpful fragment in the Samples directory included within WSDL2ObjC_v0.5_iPhone.zip.
@warhobbit, where's your WSDL? I need it to debug.
@senaimkon, "other C flags" - in the GetInfo? of target add in section "User-Defined" flag with name OTHER_CFLAGS and value "-I/usr/include/libxml2"
(http://developer.apple.com/mac/library/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html#//apple_ref/doc/uid/TP40003931-CH3-SW19)
Thanks for the great code!
Just a note to other users that v0.5 generates code where request operations for asynchronous calls retain their delegates rather than assigning them. This does not appear to be an issue at svn -r120 as these classes do not provide asynchronous calls nor their delegates.
@michael.pederson: thanks, that was bug that did still exist in -r120 which does allow asynchronous calls (see the sample code above). Bug is fixed in -r122.
How I can say about my troubles? I have simple web server, that give simple wsdl-file, but parser can't parse it. Parser version 123 has one errors, but in version 133 has another. Where and to whom I must send files ?
Please enter a bug report in the "Issues" tab. And include the wsdl file!
Hello!
I've just downloaded the project, and, upon compiling for iPhone SDK 3.0, I get a ton of "expected specifier-qualifier-list before 'IDREF'", so I think I'm missing a typedef or a library.
Any help? Thanks in advance
You don't compile the project for iPhone SDK, you compile it for Mac OS X and run it on your computer. It then generates ObjC code that works on OS X or the iPhone.
Sorry, I didn't express myself properly, I meant that I downloaded the app, generated the source files and, when I add the generated files, the iPhone project doesn't compile with that error.
submit a bug and make sure you include the wsdl (or a link to it) so it can be reproduced.
@nicolas.ameghino Did you add the lxml linker flags correctly?
@duplessis.nico Yes, everything was set up correctly. It was an issue of IDREF not being supported. hasseily added support for it on -r142.
I've been trying to use the generated code to connect to a Windows Communication Foundation webservice. I had to modify a bunch of stuff, but still could't connect. Does the project support generating code for consuming WCF services?
@nicolas.ameghino, you'd need to be more specific as to the errors that you see. The WCF WSDL is a monster, so we can only help if the bug reports are precise.
We first tried using the tool on an "out of the wizard" wcf ws but had security token issues when calling the WS. We found out about changing the WSHttpBinding to BasicHttpBinding?, which we did, but then started having errors like "415, unsupported media type" and "500, internal server error". After debugging the webservice and checking the exceptions it was throwing, we got this two error messages:
"Content Type application/soap+xml; charset=utf-8 was sent to a service expecting text/xml; charset=utf-8. The client and service bindings may be mismatched."
I tried to solve that (the boss told me to change my code instead of he checking his) by changing the content type string to the required one, but still no good.
The other error message is:
"The envelope version of the incoming message (Soap12 (http://www.w3.org/2003/05/soap-envelope)) does not match that of the encoder (Soap11 (http://schemas.xmlsoap.org/soap/envelope/)). Make sure the binding is configured with the same version as the expected messages. Parameter name: reader"
Again, I had to tweak the generated code to try make it work, but no good.
Please, let me know if you need more information, and thanks!
Looks like the WSDL says it uses SOAP 1.2, but the server expects SOAP 1.1. This is where the disconnect is. Change the WSDL of the WCF to use transport="http://schemas.xmlsoap.org/soap/envelope/" and then re-generate the code. That should generate SOAP 1.1 compliant code.
@hasseily Could that be the cause of the repeated 415 errors?
i just added the generated code to my iphone project and followed the instructions on this page, and am now getting a bunch of errors like: "error: expected ';' before '.' token", that particular error is pointing to this line "@class user.cfcSoapBinding;" of the generated code, has anybody seen anything similar to this?
Added code to my project and cloned the example code as best I could (This program really needs a working example). After submitting the request I get this in the console:
2009-09-30 23:31:39.744 efusjon[1903:20b] ResponseError?: Error Domain=NSURLErrorDomain Code=-1000 UserInfo?=0xf93b30 "bad URL"
How can I debug this?
Nevermind. I figured it out.
@Zachron, please file an issue, and make sure to include the url to the WSDL file, or the WSDL file itself. Thanks.
@nicolas.ameghino yes, that is the source of the 415 errors as well, because SOAP 1.1 uses text/xml as opposed to SOAP 1.2's application/soap+xml
@hasseily We (me+boss) couldn't find where to change the transport for the wsdl, so I downloaded it and changed it manually. It didn't work either, still popping out a 415 error. We also set the binding to BasicHTTPBinding, we've tried them all (Basic, WS and Web). When the Web binding was used, the generated code didn't have the soap actions properly set, as if the template for it were still there and not replaced with the action string.
Which files from the wsdl would you need to take a look at it?
I keep getting back:
System.Web.Services.Protocols.SoapException?: Unable to handle request without a valid action parameter. Please supply a valid soap action.
...I can see the soap action in the output header array...
{
}What am I missing?
ok, I'm really lost here. Is there a way to dump the raw request from the iphone so I can submit it via cURL or wget and see what's going on?
@ffmmpeg.php, I get the same problem wrt the soap exception. I think there is some inconsistency in the SOAP version. I can't pinpoint where the problem is, but when I modify the generated code to use content type text/xml as opposed to application/soap+xml, this problem goes away. Perhaps the server can't respond to a 1.2 request or the request is incorrectly formatted.
If I switch to that I get...
Server was unable to process request. ---> System.NullReferenceException?: Object reference not set to an instance of an object.
...which is even more confusing. How to dump raw request from cocoa?
Every soap test client I try works fine so I just need to compare output from objc to a working request but I can't figure out where to do that in my code.
ffmpeg, use the logXMLInOut property of the binding. If set to true, it'll log all the headers as well as the body itself.
Yeah, I have logXMLInOut on. Everything there looks sane. Is there some place I can put a NSLog that will spit out the raw request with headers so I can paste into cURL or wget?
Can someone make a video for me? I am a little confused about the methods and parsing the response.
ffmpeg: I don't think cocoa has the hooks to see the raw raw stuff (at least I haven't been able to find it). What you should probably do is use the simulator and have an app on your machine that grabs and dumps the network stream.
I ended up pointing the SOAP request to my apache on localhost and running mod_dumpio to get the POST data.
Okay, the problem in my case was the server wanted this...
<VerifyDistributor xmlns="http://www.es100login.com/">
..and the wsdl2objc generatede method was passing this...
<VerifyDistributor? xsi:type="DistributorSvc?:VerifyDistributor?">
I have no idea why that caused the error it did or how to properly fix it. My hack was to just add...
xmlSetProp (node, (const xmlChar)"xmlns", (const xmlChar)"http://www.es100login.com/");
...for each xmlNodeForDoc method generated by wsdl2objc.
ffmpeg, can you please create an issue ticket with this info? it'll be better for tracking.
I've just created a ticket that references the same issue ffmpeg has.
This looks pretty sweet. The iPhone app I'm hoping to write needs to be able to determine the Server to send the requests to at runtime. Is this possible with this generated code.
Thanks for any help you can give.
-ray
I'd rather think not. This app generates code for you to import into Xcode.
Hi, just downloaded and tried this generator. Worked on one WSDL, but crashed out on another. The crash report indicated a:-
Terminated app due to uncaught exception 'NSUnknownKeyException', reason: '[<USPart 0x1071870> valueForUndefinedKey:]: this class is not key complient for the key type.'
Any ideas?
The wsdl is a 3 op play wsdl with an included xsd schema file. Everything is pretty simple. There is one enum defined in the schema.
I was able to create the stubs and include in an Xcode project but am not able to compile... I get 1588 errors all due to xml issues. I downloaded and installed the xml2 lib (note there was no prerequisite notation for this library) and still getting all of the compile errors. still can't find tree.h etc
Hi first of all I must say you did great job :)
I have some problems with my test app that I'm doing based on your example. When I put your code in my view controller everything works fine I get result (response) from my web service, but when I create additional class for handling soap calls I get error like this:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: ' -operation:completedWithResponse:?: unrecognized selector sent to instance 0x3a14a00'
This is code I used:
//my controller .m file #import "Hello_SOAPViewController.h" #import "GWS_Leasing_Wrapper.h" @implementation Hello_SOAPViewController @synthesize greeting, nameInput, responseView; -(IBAction)pingClick:(id) sender { GWS_Leasing_Wrapper *gLeasing = [[GWS_Leasing_Wrapper alloc] init]; [gLeasing runPing]; responseView.text = gLeasing.result; [nameInput resignFirstResponder]; [responseView resignFirstResponder]; [gLeasing dealloc]; } @end //other class #import <Foundation/Foundation.h> #import "GWS_LeasingSvc.h" //code generated by wsdl2objc app @interface GWS_Leasing_Wrapper : NSObject { NSMutableString *result; GWS_LeasingSoap *soapCall; } @property(nonatomic,retain) NSMutableString *result; @property(nonatomic,retain) GWS_LeasingSoap *soapCall; -(void)runPing; @end //GWS_Leasing_Wrapper.m #import "GWS_Leasing_Wrapper.h" @implementation GWS_Leasing_Wrapper @synthesize result,soapCall; -(id) init { self = [super init]; if (!result) { result=[[NSMutableString alloc] init]; } if(!soapCall){ soapCall = [[GWS_LeasingSvc GWS_LeasingSoap] retain ]; } return self; } -(void) runPing { soapCall.logXMLInOut = YES; soapCall.authUsername = @"user"; soapCall.authPassword = @"pass"; GWS_LeasingSvc_Ping *cRequest = [[GWS_LeasingSvc_Ping new]autorelease]; [soapCall PingAsyncUsingParameters:cRequest delegate:self]; } - (void) operation:(GWS_LeasingSoapOperation*)operation completedWithResponse:(GWS_LeasingSoapResponse*)response { NSArray *responseHeaders = response.headers; NSArray *responseBodyParts = response.bodyParts; for(id header in responseHeaders) { } for(id bodyPart in responseBodyParts) { if ([bodyPart isKindOfClass:[SOAPFault class]]) { [result appendString:((SOAPFault *)bodyPart).simpleFaultString]; continue; } if([bodyPart isKindOfClass:[GWS_LeasingSvc_PingResponse class]]) { GWS_LeasingSvc_PingResponse *body = (GWS_LeasingSvc_PingResponse*)bodyPart; [result appendString: body.PingResult]; continue; } } } -(void)dealloc { [result release]; [soapCall release]; [super dealloc]; } @endPlease can you give me advice what I'm doing wrong (I' new to objective-c and iPhone development).
Thanks
I think you need to specify you're implementing either the Service1SoapResponseDelegate? or the Service1Soap12ResponseDelegate? protocol in your GWS_Leasing_Wrapper? class.
Hello, I tried to follow your comments, and I have still some errors when compiling, could you help me please.. thank you here my errors:
Line Location Tool:0: symbol(s) not found Line Location Tool:0: -serializedFormUsingHeaderElements:bodyElements:? in CarlinkServiceSvc?.o Line Location Tool:0: -serializedFormUsingHeaderElements:bodyElements:? in CarlinkServiceSvc?.o
Hi there,
First of all, this is GREAT work! I am still stuck with some things, though: I created the files for the following WSDL: api.mansellgroup.net/services/webservice?WSDL Now, the first thing that struck me was that the generated file XwsService?.h contains these two lines:
#import ".h" #import "XwsService?.h"
Both, of course, do not make sense. But that was easily edited. However, when generating a simple action based on this API, the request header (output to the console) looks like this:
30.12.09 19:41:18 mansellONE_TEST4486? OutputHeaders?: {
}I am stuck here as of course the request fails (I do not think it matters what the request body looks like at this point). Any ideas?
Thanks a lot!
Hm, about the Webservice I mentioned above: I just realized that every call has this same 'Soapaction' defined in wsdl2objc's output (see my post above). Weird. By now, I get a response from the server, but it is always ResponseStatus?: 500 with an error of: <soapenv:Body>
Now, I am no expert on XML & SOAP, but doesn't that mean something about the name space or node nesting is wrong?
Any help is appreciated!
Comment by jcreech851, Yesterday (19 hours ago) for the line of Code that says:
unsignedByte PatientFlag?;
I am coming back with an error:
error: expected specifier-qualifier-list before 'unsignedByte'
Anybody have any idea what that's from?
Thanks!
hi,
is the output which is logged by logXmlInOut = YES all the information that is recieved? I wrote a test app where i recieve like let's say 10kb. An i tried it with edge, and it feels like that it takes to long (8-12 seconds sometimes a little bit faster if the connection is good - 2 or 3 second could be server-side processing max.). I don't know how to investigate where my time is being spend any suggestions?
I'm using it with a .NET Web Service, parameters are not being sent. Anyone got this?
Thank you so much for this. Is really was a life saver as this is the basis of my application. It took me a while to get it going to get the hang of the syntax and all the nested elements that were in my webservices. It was definately worth it. My objects are now all successfully saving into Core Data.
One thing I did need to change in the connectionDidFinishLoading function for all methods was this (note the line that was there was commented and the new line below:
for(bodyNode=cur->children ; bodyNode != NULL ; bodyNode = bodyNode->next) {
This allowed me to parse the elements correctly.
Is there any sample code on how to use this?. More sample code would be really useful.
It's a shame it's non-free, even though the app itself is MIT, the code it generates contains the following notice:
Can you confirm that the code generated by the app is, indeed, under a usable license or shall I contact these companies for licenses to use code generated by your MIT licensed app?
GC
Does it have iisue to open 2 connections to 2 different server ?
Does anyone have gotten 400 error from server using this lib??
Thanks to help me.
Would someone be able to post some detailed examples of how to use the code this generates please?
As mentioned above, there are a few sample files in the SVN repo, but no real explanations of how to use them. My code compiles and installs using the tool in the latest build but I haven't got a clue how to recover some simple results that return a list of clients.... PLEEEEEASE would someone do a quick step by step example of getting some data out... or even documenting the code that's in the sample files so we can use this tool that you've put so much work into?! Thanks sooo much! Similar request here: http://stackoverflow.com/questions/2575284/webservices-on-iphone-wsdl2objc-sample-code
Crashes when I try to use it:
I also crash there, it is caused by bodyNode->ns->prefix, Add a condition to check (bodyNode->ns) before it seems fixed.
Please help. I'm willing to pay a consulting fee.
I recently purchased a new MaxBook? Pro. It is running Mac OS X Version 10.6.3. I have downloaded Xcode 3.2.3 and the IPhone SDK 4 (Beta). I have run the wsdl2objc tool against my Web Service. My Web Service returns a single line of text. No XML processing is required. I have a simple text project that has a button and a label. I would like to call my Web Service and show the result in the label. I have installed all the generated code and libraries, and my test application runs O.K.
I, like others on this list, am having trouble with how to call the generated code to access my Web Service.
I am willing to send my entire project (in a Zip file) and pay a consulting fee to get me started. I expect that only a few lines of code need to be added to my test program, and it should take less than a hour.
Anyone interested?
Please contact me with you one hour consulting fee.
Charles Brauer CBrauer@CypressPoint?.com
@mark.mcgookin, did you read the sample usage at the top of this page? You've got to:
I'm working on a sample iPhone app for the .tel TelPages? webservice, I'll post it asap. It'll be exceedingly simple.
Here's another very simple sample usage of a SOAP webservice: it runs a search on the .tel Telpages search API and returns results. The UI is a searchcontroller with very minimal code.
http://dev.telnic.org/trac/browser/apps/iphone/TelPages/Classes/TelPagesViewController.m
how to get the binding. someone can supply a sample. Any help is appreciated!
Hi, I did everything according this tutorial, but I always get 1 error: "Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1"
Can somebody explain me what am I doing wrong?
@teafoos that's not enough info. What's the error in the console? Where is the error happening?
@hasseily: XCode don`t show me where the error is, only shows error message.
// BEGINNING //
ProcessPCH /var/folders/8b/8bVVVSAdEp8Xxt0PqIsigE+++TI/-Caches-/com.apple.Xcode.501/SharedPrecompiledHeaders?/testWSDL_code_Prefix-ditjaezjfrbvntbpndrwhucxxele/testWSDL_code_Prefix.pch.gch testWSDL_code_Prefix.pch normal i386 objective-c com.apple.compilers.gcc.4_2 cd /Users/rackom/Dropbox/Programing/iPhone_development/testWSDL_code setenv LANG en_US.US-ASCII setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -x objective-c-header -arch i386 -fmessage-length=0 -pipe -std=c99 -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused-variable -DIPHONE_OS_VERSION_MIN_REQUIRED=30000 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.3.sdk -fvisibility=hidden -mmacosx-version-min=10.5 -gdwarf-2 -iquote /Users/rackom/Dropbox/Programing/iPhone_development/testWSDL_code/build/testWSDL_code.build/Debug-iphonesimulator/testWSDL_code.build/testWSDL_code-generated-files.hmap -I/Users/rackom/Dropbox/Programing/iPhone_development/testWSDL_code/build/testWSDL_code.build/Debug-iphonesimulator/testWSDL_code.build/testWSDL_code-own-target-headers.hmap -I/Users/rackom/Dropbox/Programing/iPhone_development/testWSDL_code/build/testWSDL_code.build/Debug-iphonesimulator/testWSDL_code.build/testWSDL_code-all-target-headers.hmap -iquote /Users/rackom/Dropbox/Programing/iPhone_development/testWSDL_code/build/testWSDL_code.build/Debug-iphonesimulator/testWSDL_code.build/testWSDL_code-project-headers.hmap -F/Users/rackom/Dropbox/Programing/iPhone_development/testWSDL_code/build/Debug-iphonesimulator -I/Users/rackom/Dropbox/Programing/iPhone_development/testWSDL_code/build/Debug-iphonesimulator/include -I/Users/rackom/Dropbox/Programing/iPhone_development/testWSDL_code/build/testWSDL_code.build/Debug-iphonesimulator/testWSDL_code.build/DerivedSources?/i386 -I/Users/rackom/Dropbox/Programing/iPhone_development/testWSDL_code/build/testWSDL_code.build/Debug-iphonesimulator/testWSDL_code.build/DerivedSources? /usr/include/libxml2 -c /Users/rackom/Dropbox/Programing/iPhone_development/testWSDL_code/testWSDL_code_Prefix.pch -o /var/folders/8b/8bVVVSAdEp8Xxt0PqIsigE+++TI/-Caches-/com.apple.Xcode.501/SharedPrecompiledHeaders?/testWSDL_code_Prefix-ditjaezjfrbvntbpndrwhucxxele/testWSDL_code_Prefix.pch.gch
i686-apple-darwin10-gcc-4.2.1: cannot specify -o with -c or -S with multiple files Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1
// END //
@teafoos it looks like the crash is in the compile. Please do a menu Build > Clean all targets, and try again. Otherwise it may be that your project has a configuration problem.
@hasseily: I cleaned all targets, but the same error. Can it be caused by incorrectly written wsdl? I think not, but better to ask first. But using other tool for conversion wsdl2objc I had no problems. Ill run through my project and check once again everything, hope Ill find the problem.
hmmm no help :( I used 0.7b version of converter ... could that be the problem?
Having trouble compiling, it fails during linking Im getting:
Undefined symbols:
"OBJC_CLASS$notifyrefreshNotificationsResponseType", referenced from: "OBJC_CLASS$notifygetMetaDataResponseType", referenced from: notifygetMetaDataResponseType in NOTIFY.o "OBJC_CLASS$notifygetCommandSchemaResponseType", referenced from: "OBJC_CLASS$notifyregisterListenerResponseType", referenced from: notifyregisterListenerResponseType in NOTIFY.o "OBJC_CLASS$notifyloginResponseType", referenced from: "OBJC_CLASS$notifygetNotificationResponseType", referenced from: notifygetNotificationResponseType in NOTIFY.o "OBJC_CLASS$notifygetNotificationDefinitionsResponseType", referenced from: "OBJC_CLASS$notifylogoutResponseType", referenced from: notifylogoutResponseType in NOTIFY.o "OBJC_CLASS$notifygetNotificationIdsResponseType", referenced from: "OBJC_CLASS$notifyexecuteCommandResponseType", referenced from: notifyexecuteCommandResponseType in NOTIFY.o "OBJC_CLASS$notifygetDomainValuesResponseType", referenced from: ld: symbol(s) not foundFor bug reports, please use the issues tab on top of this page. We need specific info to track down problems, and must be able to track them properly as well.
I'm getting the exact same issues, will create a ticket with more info
I've got a WSDL service with two operations. The generated code is more convoluted than most of the examples I've seen here. In particular, I've got no myOperationUsingParameters method on my bindings object. What do I call instead? Any examples I can work from?
Thanks!
Hi, first thanks for your great work.
I ve used the trunk version of the project to generate the classes, but from my wsdl (contains complex types) there are no attribute values in the responseBody.
I did everything like in the instructions. But it seem like the serialization ignores attributes. The following function is empty for all generated classes:
(void)deserializeAttributesFromNode:(xmlNodePtr)cur { }
while the "(void)deserializeElementsFromNode:(xmlNodePtr)cur" has the logic to serialize elements.
The 2 functions are called while serialization, so I ve no filled object with the response attributes values.
Do I need to implement it by my self or is it a mistake in my generation.
Please help me.
Thanks.
@stylecrax, please create an issue and post your WSDL (or a link to it). @dwardox, same thing please. It looks like a WSDL parsing issue.
@hasseily: I ve created an issue..and wrote a short description. Can you please give me any feedback on this one=? Would be great. Let me please also know if you got the wsdl. Thanks for your help.
This has been a tremendously useful utility! Thank-you very much for sharing.
I do have one request. Could you please make the generated code expose the SOAP headers? I have some services in which additional SOAP headers are required. I realize I can tweak the generated code, but that's something I hate doing. It would be much simpler if the "headerElements" could be set.
By the way, if that's already possible, please accept my apology and tell me how. :-)
Thanks!
To access the headers:
NSArray *responseHeaders = response.headers; for(id header in responseHeaders) { ... }Apparently I wasn't clear enough. I was talking about the REQUEST headers, not the response headers. More specifically, I'm talking about the SOAP headers, not the HTTP headers, on the request. In the generated code, these are the headerElements that get passed to "serializedFormUsingHeaderElements".
The interesting thing is that the code to handle the headers in the actual request (i.e. the code within "serializedFormUsingHeaderElements") is there and works like a charm. It's just that the headers are not exposed externally, as far as I can tell.
Thanks!
Generated source files with 0.7 here, added the flags to the project settings, but when I try to compile I get the following linker errors:
Ld ../../build/Debug-iphonesimulator/Monitor-iPhone.app/Monitor-iPhone normal i386 cd /Users/cstromme/Projects/Monitor/src setenv MACOSX_DEPLOYMENT_TARGET 10.6 setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk -L/Users/cstromme/Projects/Monitor/src/../../build/Debug-iphonesimulator -L/Users/cstromme/Projects/Monitor/src/../../Build/Debug-iphonesimulator -F/Users/cstromme/Projects/Monitor/src/../../build/Debug-iphonesimulator -filelist /Users/cstromme/Projects/Monitor/src/../../build/Monitor-iPhone.build/Debug-iphonesimulator/Monitor-iPhone.build/Objects-normal/i386/Monitor-iPhone.LinkFileList? -mmacosx-version-min=10.6 -all_load -ObjC -Xlinker -objc_abi_version -Xlinker 2 -framework Foundation -framework UIKit -framework CoreGraphics? -framework QuartzCore? /Users/cstromme/Projects/build/Debug-iphonesimulator/libCorePlot-CocoaTouch?.a -framework CFNetwork -o /Users/cstromme/Projects/Monitor/src/../../build/Debug-iphonesimulator/Monitor-iPhone.app/Monitor-iPhone
Undefined symbols:
ld: symbol(s) not found collect2: ld returned 1 exit statusSo what's wrong here?
I'm on XCode 3.2.3, under 10.6.4 with Base SDK set to 4.0.
I had the same issue as ffmpeg about the missing xmlns properties for each call. i got an 500 about bad structure elements. i solved it manually by replacing the type property in each xmlNodeForDoc. but ffmpegs post is missing the pointer reference. so the correct way is:
wrong code generated //xmlSetNsProp(node, xsi, (const xmlChar*)"type", (const xmlChar*)"BLZService:getBankResponseType");
rght code manually added (replace URL traget by your ws-url): ixmlSetProp (node, (const xmlChar*)"xmlns", (const xmlChar*)"http://thomas-bayer.com/blz/");
Can I get some help? I keep getting this
error: expected specifier-qualifier-list before 'Value' on a line with this : Value Value;
I also get this in the generated code: / elements / %«element.type.classNameWithPtr» ERROR: undefined key %«element.name» ERROR: undefined key ;
Here is the WSDL http://api.exigo.com/3.0/ExigoApi.asmx?WSDL
In need to invoke JAX-WS web service from iPhone. wsdl2objc works fine if the web service is created with .NET (I have followed a tutorial): created service1.h/.m are ok, and I manage to invoke the service using
Service1SoapBinding? binding = [Service1SoapBinding? initWithAddress:@"http://address/Service1.asmx"];
etc.
But with a JAX-WS service, generated code appears uncomplete to me. Fore example, there are no Service1SoapBinding?, Service1 interfaces...
There is, instead: Service1PortBinding?.. (for example) Can someone provide a tutorial?
Thanks
@michele.amoretti
I have the same problem... have you a answer??
tanks
In case others are still having this problem. I was getting the following error initially. %«element.type.classNameWithPtr» ERROR: undefined key %«element.name» ERROR: undefined key ;
It turned out that the issue was that the referenced xsd namespace files were not accessible. In my case I had to place them in the appropriate location on my local system before it would generate the code correctly.
Note the "schemaLocation" attribute for the path to where the files should be placed in relation to the wsdl.
Hi friends i am facing below error faultstring>org.xml.sax.SAXParseException: Element or attribute do not match QName production: QName::=(NCName':')?NCName.</faultstring>
please help me
I am trying to generate the files of a wsdl file and when the Parse WSDL is pressed occurs the following: 1.- the string ".1; /Users/cursoeii/Downloads/ADAService.wsdl.xml" is append to the WSDL path browsed
2.- The application shows that the parse has "Finished!"
However, no files are generated.
Please help me.
Solved!!, there were read only permissions to "every user" and I have changed it to read-write.
hi,
I generated code successfully but I am not able to use this, I am confused too much with the generated code, and I am not getting which class objects i have to create. can anybody plese give one full example how exactly to use code.
Thanks, Shiva
i did exactly same as you described although i am getting response from my service but it is null because i am not able to pass the parameter . In my case as i am passing two string it should return concatenation of two strings but it is returning null.
here is my code...
- (BOOL)application:(UIApplication )application didFinishLaunchingWithOptions:(NSDictionary )launchOptions {
WsdlRequest?.arg0=@"vineet"; WsdlRequest?.arg1=@"sharma"; ejbfunctiontestAsyncUsingParameters:WsdlRequest delegate:self?;
}- (void) operation:(ConcatefunctionBindingOperation? )operation completedWithResponse:(ConcatefunctionBindingResponse? )response {
{ }and this what i am getting in console:
started at 2011-04-26 02:29:14 -0700.? 2011-04-26 02:29:29.128 ConcateWsdl?[4174:207] OutputHeaders?: {
} 2011-04-26 02:29:29.149 ConcateWsdl?[4174:207] OutputBody?: <?xml version="1.0"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ConcatefunctionService?="http://incture.com/" xsl:version="1.0"> </soap:Envelope> 2011-04-26 02:29:29.250 ConcateWsdl?[4174:207] ResponseStatus?: 200 2011-04-26 02:29:29.268 ConcateWsdl?[4174:207] ResponseHeaders?: { } 2011-04-26 02:29:29.286 ConcateWsdl?[4174:207] ResponseBody?: <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Body><ns2:ejbfunctiontestResponse xmlns:ns2='http://incture.com/'><return>nullnull</return></ns2:ejbfunctiontestResponse></SOAP-ENV:Body></SOAP-ENV:Envelope> 2011-04-26 02:29:29.306 ConcateWsdl?[4174:207] the return is :nullnullPlease help me regarding this ..
and one more thing i want to ask is that is there any help or documents for the service which is taking complex type (other than primitive types like object or list of object,DTO etc)as input??
Please respond
Thanks and Regards
vinit sharma
@vinit, it's impossible to tell if you're using it correctly since we can't see your WSDL/XSD. The easiest would be for you to post (using proper Wiki syntax for pasting code, not direct copy-paste as you did) a working request XML that you know works, from some other tool.
@Shiva, there is an example at the top of this page, where you use a command to request the favorite color of a friend named "Johnny". Is that not enough for you? You don't need to look at the generated code at all. You just need to do the following:
You'll get back a response object that you can parse for the items you want. People get tripped up in general when creating objects for the request, they assume that everything was created when the request was created. That is not true: you must allocate/init (or new) every object you'll be using in the request, including nested objects. The framework won't create all the objects for you, as it doesn't know what you'll be using.
Thanks for your reply :)
- (BOOL)application:(UIApplication )application didFinishLaunchingWithOptions:(NSDictionary )launchOptions {
WsdlRequest?.arg0=@"vineet"; WsdlRequest?.arg1=@"sharma"; ejbfunctiontestAsyncUsingParameters:WsdlRequest delegate:self?;
}- (void) operation:(ConcatefunctionBindingOperation? )operation completedWithResponse:(ConcatefunctionBindingResponse? )response {
{ }Thanks and Regards
vinit sharma
@vinit, I need to see the XML request generated by WS-NAVIGATOR. Then we'll see what the difference is between that working XML request and the non-working XML request of wsdl2objc.
Hi,
This is the xml which i am parsing through wsdl2objc.
- <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://incture.com/" targetNamespace="http://incture.com/"> - <wsdl:types> - <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://incture.com/" version="1.0">
- <xs:complexType name="ejbfunctiontest"> - <xs:sequence> - <xs:complexType name="ejbfunctiontestResponse"> - <xs:sequence> - <wsdl:message name="ejbfunctiontestIn"> - <wsdl:message name="ejbfunctiontestOut"> - <wsdl:portType name="Concatefunction"> - <wsdl:operation name="ejbfunctiontest" parameterOrder="parameters"> - <wsdl:binding xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" name="ConcatefunctionBinding?" type="tns:Concatefunction"> - <wsdl:operation name="ejbfunctiontest"> - <wsdl:input> - <wsdl:output> - <wsdl:service name="ConcatefunctionService"> - <wsdl:port binding="tns:ConcatefunctionBinding" name="ConcatefunctionPort">Thanks and Regards
Vinit Sharma
Hi, Please respond as i am not able to consume web service
Thanks and Regards
Vinit Sharma
I used wsdl2obj to test if it works for our ws, it dont. But really would like it to! This XML works: {<soapenv:Envelope
</soapenv:Envelope>}And this generated by wsdl2objc dont work, any ideas?
{<?xml version="1.0"?> <soapenv:Envelope
</soapenv:Envelope>}@vinit I'm not interested in the wsdl, I'm asking you to look at the difference between the generated soap code by wsdl2objc and the generated soap code that works.
@matsekb do you have access to the server log? what error does it throw? I don't see a difference except that wsdl2objc uses xsi:type while your ws uses direct typing.
Can someone tell me if this will work for a WCF service using JSON? Thanks.
i did exactly same as you described although i am getting response from my service but it is null. It is showing error message as: ResponseError?: Error Domain=BingPortBindingResponseHTTP Code=505 "unsupported version" UserInfo?=0x4c94df0 {NSLocalizedDescription=unsupported version}
here is my code:
Can anyone help me regarding this.
Hi, I have a problem with a SAP web service.. I converted it using WSDL2OBJC and then executed in an app..
The result however is not good..
I configured the resulting ".m" for the webservice for SAP usage. So it's a bit different from general output. Also modified some parameters to make the call like SoapUI output... You could see those changes.. Here is the execution log:
2011-07-20 13:20:38.874 navigation2[2922:40b] Onay2 Current language: auto; currently objective-c 2011-07-20 13:20:48.424 navigation2[2922:40b] OutputHeaders: { "Content-Length" = 357; "Content-Type" = "application/soap+xml; charset=utf-8"; Host = "cpi.caliknet.calik"; Soapaction = ""; "User-Agent" = wsdl2objc; } 2011-07-20 13:20:48.425 navigation2[2922:40b] OutputBody: <?xml version="1.0"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:sap-com:document:sap:soap:functions:mc-style"> <soapenv:Body> <urn:ZfmSatonay> <IBsart></IBsart> <IErdat></IErdat> <ITarget>Q</ITarget> <IWerks></IWerks> </urn:ZfmSatonay> </soapenv:Body> </soapenv:Envelope> 2011-07-20 13:21:45.328 navigation2[2922:40b] ResponseStatus: 500 2011-07-20 13:21:45.329 navigation2[2922:40b] ResponseHeaders: { Accept = "text/xml"; "Content-Length" = 1801; "Content-Type" = "text/xml; charset=utf-8"; "Sap-Srt_id" = "20110720/132116/v1.00_final_6.40/00505690250A1EE0ACD7400E7484086F"; Server = "SAP NetWeaver Application Server / ABAP 711"; } 2011-07-20 13:21:45.330 navigation2[2922:40b] ResponseError: Error Domain=ZMOBILE_SDBindingResponseHTTP Code=500 "internal server error" UserInfo=0x4e23580 {NSLocalizedDescription=internal server error}The same output body executes in soapUI without any problem, but in app it gives internal server error. What could be the problem..
Here is the code I used to execute web service:
ZMOBILE_SDBinding *binding = [ZMOBILE_SDService ZMOBILE_SDBinding]; binding.logXMLInOut = YES; binding.authUsername =@"hatac"; binding.authPassword =@"*******"; ZMOBILE_SDService_ZfmSatonay *request = [[ZMOBILE_SDService_ZfmSatonay new] autorelease]; request.ITarget = @"Q"; request.IErdat = @""; request.IWerks = @""; request.IBsart = @""; ZMOBILE_SDBindingResponse *response = [binding ZfmSatonayUsingParameters:request];This service also has authentication but I didn't see any authentication code in outputbody, in SoapUI I also see authorization in header:
Input XML:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:sap-com:document:sap:soap:functions:mc-style"> <soapenv:Body> <urn:ZfmSatonay> <IBsart></IBsart> <IErdat></IErdat> <ITarget>Q</ITarget> <IWerks></IWerks> </urn:ZfmSatonay> </soapenv:Body> </soapenv:Envelope>Output XML:
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"> <soap-env:Header/> <soap-env:Body> <n0:ZfmSatonayResponse xmlns:n0="urn:sap-com:document:sap:soap:functions:mc-style"> <ESatonay/> </n0:ZfmSatonayResponse> </soap-env:Body> </soap-env:Envelope>Inoput header as RAW:
Output header as raw:
Can you help me about this problem?!?
Solved via compiling with latest source from SVN. Now authentication is working correctly.
Hello? Quick question.
for (id bodyPart in responseBodyParts) {
}result is supposed to be an xml file, however I have no idea how to parse it. Can someone teach me how? thanks
Will there be any support for adding xml attributes to elements?
@mgogsw - Can you elaborate a bit more on this part:
"It turned out that the issue was that the referenced xsd namespace files were not accessible. In my case I had to place them in the appropriate location on my local system before it would generate the code correctly."
I'm currently generating code with the "%«element.type.classNameWithPtr» ERROR: undefined key %«element.name» ERROR: undefined key ;" problem, using the WSDL found here: https://agpro.hortus.net.au/security.asmx?WSDL
...what files do I need to download and where do I need to set the "schemaLocation" attribute in order to make this work?
Hi, I have the same problem like nicolas.ameghino had. When I use basicHttpBinding, I receive: "415, unsupported media type". Hasseily said about it: "Looks like the WSDL says it uses SOAP 1.2, but the server expects SOAP 1.1. This is where the disconnect is. Change the WSDL of the WCF to use transport="http://schemas.xmlsoap.org/soap/envelope/" and then re-generate the code. That should generate SOAP 1.1 compliant code." But I couldn't find out how to modify the WCF service (C sharp) in order to change the "transport" attribute. Can you help me please?
The tool is creating variables, which do not satisfy varibale declarations rules and results in compile time errors.
for eg
It creates a variable with "-" instead of underscore ""
This tool is not the very best tool to use, at least not with the Java CXF. It builds incorrect xml with wrong and additional prefixes. Apart from that, the documentation is poor. If you follow it you get the compilation errors. Missing inclusion under Build settings of "Header Search Paths = /usr/include/libxml2". Tried SudZ, similar stuff.
I guess there is nothing left apart from building the SOAP request from scratch using the NSURLConnection obect.