0
NSString *urlString = @"http://172.29.165.219:8090/abc/services/Abc";
NSString *soapMessage = [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"
                         "<getUserInfo>\n"
                         "<email>%@</email>\n"
                         "<pwd>%@</pwd>\n"
                         "</getUserInfo>\n"
                         "</soap:Body>\n"
                         "</soap:Envelope>\n", @"babla.sharan@tcs.com",@"UGFzc0AxMjM="//,@"50006F0063006B0065007400500043000000-444556494345454D00",@"PocketPC"
                         ];
NSMutableURLRequest *loginRequest = [RequestGenerator -generateSOAPRequestWithURLString:urlString soapMessage:soapMessage contentType:@"text/xml; charset=utf-8" action:@"getUserInfo"];
WebServiceHandler *connection = [[WebServiceHandler alloc]init];

对于上面的代码,它工作正常,但是当我将附加标签作为父标签添加到 id 和密码时

NSString *urlString = @"http://172.29.165.219:8090/abc/services/Abc";
NSString *soapMessage = [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"
                         "<getUserInfo>\n"
                         **"<ABC>\n"**
                                                     "<email>%@</email>\n"
                         "<pwd>%@</pwd>\n"
                                                     **"</ABC>\n"**
                         "</getUserInfo>\n"
                         "</soap:Body>\n"
                         "</soap:Envelope>\n", @"babla.sharan@tcs.com",@"UGFzc0AxMjM="//,@"50006F0063006B0065007400500043000000-444556494345454D00",@"PocketPC"
                         ];
NSMutableURLRequest *loginRequest = [RequestGenerator generateSOAPRequestWithURLString:urlString soapMessage:soapMessage contentType:@"text/xml; charset=utf-8" action:@"getUserInfo"];
WebServiceHandler *connection = [[WebServiceHandler alloc]init];

它显示异常并收到此错误:

org.xml.sax.SAXException:SimpleDeserializer 在尝试反序列化的过程中遇到了一个子元素,这不是预期的。

它甚至不允许我访问服务器。

4

1 回答 1

0

在第二条肥皂消息中,您正在为您的信息发送一个额外的父标签,您的服务器可能无法识别该标签。如果这个标签是可选的,那么应该没有问题,但如果它是不受欢迎的,那么你不应该使用它。以下是 W3.org(http://www.w3.org/TR/2000/NOTE-SOAP-20000508/) .... 的摘录,其中讲述了soap 请求的接收和处理。

A SOAP application receiving a SOAP message MUST process that message by performing 
    the following actions in the order listed below:

         1. Identify all parts of the SOAP message intended for that application 
         2. Verify that all mandatory parts identified in step 1 are supported by
 the  application for this message (see section 4.2.3) and process them accordingly.
 If this is   not the case then discard the message .
 The processor MAY ignore optional parts identified in step 1 without affecting the outcome of the processing.
        3. If the SOAP application is not the ultimate destination of the message then
     remove all parts identified in step 1 before forwarding the message.


  Processing a message or a part of a message requires that the SOAP processor 
  understands, among other things, the exchange pattern being used (one way, 
  request/response, multicast, etc.), the role of the recipient in that pattern, the 
  employment (if any) of RPC mechanisms such as the one documented in section 7, the 
  representation or encoding of data, as well as other semantics necessary for correct 
  processing
于 2011-04-12T12:22:24.057 回答