webservice call from wsdl-files with authorization

Discussion in 'iOS Programming' started by drossbach, Dec 18, 2008.

  1. drossbach macrumors newbie

    Dec 18, 2008
    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!
  2. drossbach thread starter macrumors newbie

    Dec 18, 2008
    Add XML-Header information

    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:mad:"key1", @"key2", @"key3", nil];
    NSArray *objects = [NSArray arrayWithObjects:mad:"value1", @"value2", @"value3", nil];
    NSDictionary *dictionary = [NSDictionary dictionaryWithObjects:eek:bjects forKeys:keys];

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

    I hope that will help other persons as well!

Share This Page