2011-07-27 60 views
1

我試圖使用ASIFormDataRequest請求wsdl服務,但它沒有正確回覆。你可以請任何人指導什麼是我的錯。如何在iPhone的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]; 

回答

0

我使用ASIFormDataRequest,我認爲這是最好的網絡框架。而且它也很容易使用。嘗試刪除自定義選擇器,並將NSLog放入-asyncSuccess:方法中。

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

如果NSLog被調用,您可以通過[request responseString][request responseData]獲取服務器的輸出。

+0

我收到了[request responseString]的請求。 – Gnanavadivelu

+0

但是你的問題是什麼?它是否爲'NULL'?問題是什麼? – akashivskyy

+0

HTTP/1.0 404 Not Found X-Cache:來自local.sdi.local的MISS 服務器:Apache 過期時間:Wed,27 Jul 2011 09:49:19 GMT X-Cache-Lookup:MISS from local.sdi。本地:3128 Via:1.0 local.sdi.local(squid/3.0.STABLE13) 代理連接:關閉 變化:接受語言,接受字符集 Content-Language:en Content-Type:text/html; charset = iso-8859-1 Date:Wed,27 Jul 2011 09:49:19 GMT Accept-Ranges:bytes – Gnanavadivelu