2011-04-12 79 views
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", @"[email protected]",@"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和密碼SOAP消息的錯誤

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", @"[email protected]",@"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 encountered a child element, which is NOT expected, in something it was trying to deserialize.

它甚至不允許我打到服務器。

+0

你試圖使標籤ABC像,而不是? – 2011-04-12 12:00:27

+0

在服務器端,你有這個新的標籤識別嗎? – Ravin 2011-04-12 12:04:43

回答

0

在第二條肥皂消息中,您正在爲您發送一個附加的父標記信息,這可能無法被您的服務器識別。如果這個標籤是可選的,那麼根本不應該有任何問題,但如果這是不受歡迎的,那麼你就不應該使用它。以下是來自W3.org的摘錄(http://www.w3.org/TR/2000/NOTE-SOAP-20000508/),它講述了肥皂請求的接收和處理。

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