View Full Version : webservice call from wsdl-files with authorization

Dec 18, 2008, 02:34 AM
I used WSMakeStubs to create an ObjC-code from a given wsdl-File and I imported these code-files into my iPhone project. Now I have several functions the webservice provides to me, I can call them this way:

NSData *data =[WebServiceClass functionfromWebservice: parameter]

In "data" is the return code from the webservice.

My question is how to add a BASIC authorization to the webservice-call: username & key?

I know that the call creates a XML-code and transfers it to the URL where the webservice is called. So I need a function to add the authoization to this XML-segment.
If anybody knows how to do this, please help!

Dec 19, 2008, 02:13 AM
I found out a solution for my own problem and want to tell this for users that have the same problem:

The app WSMakeStubs creates 4 files: WSGeneratedObj(.h)(.m) & OwnClassName(h).(m)

The WSGeneratedObj.m file creates the XML-Header, before the webservice is called ( in function "WSMethodInvocationRef) createInvocationRef(params...)" - I do not exactly know, if the name is always the same.

The functions of the webservice are defined in the OwnClassName-Files, they call the "createInvocationRef"-function with their parameters.

In this function is a header defined:

NSDictionary* headername = ...

This is the part where to add new information, for example an authorization.

NSArray *keys = [NSArray arrayWithObjects:@"key1", @"key2", @"key3", nil];
NSArray *objects = [NSArray arrayWithObjects:@"value1", @"value2", @"value3", nil];
NSDictionary *dictionary = [NSDictionary dictionaryWithObjects:objects forKeys:keys];

This example adds 3 entries to to the header with the 3 keys.

I hope that will help other persons as well!