1

我尝试使用 ASIFormDataRequest 请求 wsdl 服务,但没有正确回复。你能请任何人指导我的错吗?

#define SIGNON @"http://smile.stanford.edu:8080/SMILE/spring-ws/StudentSignOn.wsdl"



    NSString *Message  = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
                          "<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/\">\n"
                          "<soap:Body>\n"
                          "<stdSignon xmlns=\"http://tempuri.org/\">\n"
                          "<username>%@</username>\n"
                          "<password>%@</password>\n"
                          "</stdSignon>\n"
                          "</soap:Body>\n"
                          "</soap:Envelope>\n",txtUserName.text,txtPassword.text];


    NSMutableData *soapdata = [[[NSMutableData alloc] initWithData:[Message dataUsingEncoding:NSUTF8StringEncoding]] autorelease];

    ASIFormDataRequest *_ASIFormDataRequest = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:SIGNON]];
    [_ASIFormDataRequest addRequestHeader:@"Namespace" value:@"http://stanford.edu/smile/studentsignon/schema"];    
    [_ASIFormDataRequest addRequestHeader:@"Content-Type" value:@"text/xml; charset=utf-8"];
    [_ASIFormDataRequest addRequestHeader:@"EndpointURI" value:@"http://stanford.edu/smile/studentsignon"];
    [_ASIFormDataRequest setTimeOutSeconds:20];
    [_ASIFormDataRequest setPostBody:soapdata];



#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0
    [_ASIFormDataRequest setShouldContinueWhenAppEntersBackground:YES];
#endif
    [_ASIFormDataRequest setDelegate:self];
    [_ASIFormDataRequest setDidFailSelector:@selector(asyncFail:)];
    [_ASIFormDataRequest setDidFinishSelector:@selector(asyncSuccess:)];
    [_ASIFormDataRequest startAsynchronous];
4

1 回答 1

0

我使用ASIFormDataRequest并且我认为它是最好的网络框架。而且它也很容易使用。尝试删除自定义选择器并放入NSLog方法-asyncSuccess:

- (void)asyncSuccess:(ASIFormDataRequest *)request {
    NSLog(@"finished");
    // your code from asyncSuccess:
}

如果NSLog被调用,您可以通过[request responseString]或获取服务器输出[request responseData]

于 2011-07-27T09:42:17.297 回答