【问题标题】:How to use wsdl in ASIFormDataRequest in iphone如何在 iphone 的 ASIFormDataRequest 中使用 wsdl
【发布时间】:2011-07-27 09:03:14
【问题描述】:

我尝试使用 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];

【问题讨论】:

    标签: iphone soap asihttprequest asiformdatarequest


    【解决方案1】:

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

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

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

    【讨论】:

    • 我收到了来自 [request responseString] 的请求。
    • 但是你的问题是什么?是NULL吗?有什么问题?
    • HTTP/1.0 404 Not Found X-Cache: MISS from local.sdi.local 服务器: Apache Expires: Wed, 27 Jul 2011 09:49:19 GMT X-Cache-Lookup: MISS from local .sdi.local:3128 通过:1.0 local.sdi.local (squid/3.0.STABLE13) 代理连接:关闭 变化:accept-language,accept-charset Content-Language: en Content-Type: text/html; charset=iso-8859-1 日期:2011 年 7 月 27 日星期三 09:49:19 GMT 接受范围:字节
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-18
    • 2011-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多