Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.8k views
in Technique[技术] by (71.8m points)

iphone - Need help on Objective-C code (WSDL2ObjC generated)

In the WSDL2ObjC documentation there is a sample code like below, but in my generated code I couldnt find any class, method or property equavilant to "myOperationUsingParameters" what is that and where can I find it? I don't know also what "myOperation" and what "ns1" is.

I'm newbie, so in Objective C maybe there is a meaning when I change the capitals of variables in a certain way and concatenate them with some keywords?

for instance: ns1_MyOperationRequest -- myOperationUsingParameters

tnx

#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];
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

All depends on your web service class name etc as wsdl2objc makes up alot of your NSObjects and methods based upon this, however, suggesting that you are using soap 1.2 bindings and your web service was called 'SimpleService', the following would call a web method named 'MobileTestService and return back the integer value from the xml generated.

-(NSString *)returnThatStringFromWebServiceResult 

{


SimpleServiceSoap12Binding * binding = [SimpleService SimpleServiceSoap12Binding];

binding.logXMLInOut = YES; // shows all in the console log.

SimpleService_concat * testParams = [[SimpleService_concat new]autorelease];

testParams.s1 = someTextField.text; // parameters all become properties of this testParams object

testParams.s2 = anotherTextField.text;

SimpleServiceSoap12BindingResponse * response= [binding SimpleService_concatUsingParameters:testParams];

[response self]; // removes compile error

NSArray * responseBodyParts = response.bodyParts;

NSError * responseError = response.error;

if (responseError!=NULL) 

{
    return @"";     // if error from ws use [responeError code]; for http err code


}

for (id bodyPart in responseBodyParts)

{

    if ([bodyPart isKindOfClass:[SimpleService_concat_Response class]]) 

    {
        SimpleService_concatResponse* body = (SimpleService_concatResponse*) bodyPart;

        return body.SimpleService_concatResult; // if you are returning a string from your WS then this value will be a string, 

    }

}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...