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 と password に追加すると

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

ここで 2 番目の SOAP メッセージでは、追加の親タグを送信して情報を提供していますが、これはサーバーによって認識されない可能性があります。このタグがオプションである場合はまったく問題はありませんが、望ましくない場合は使用しないでください。以下は 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 に答える