带有附加 XML 标记的 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"
"<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 和密码时,
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 在尝试反序列化的过程中遇到了意外的子元素。
它甚至不允许我访问服务器。
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];
For the Above code, it works fine, but when I add additional Tag as parent tag to id and 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", @"[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];
It shows exception and get this error:
org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
It doesn't even allow me to hit the server.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在第二个肥皂消息中,您正在为您的信息发送一个额外的父标签,您的服务器可能无法识别该父标签。如果这个标签是可选的,那么应该没有问题,但如果它是不需要的,那么你不应该使用它。以下是 W3.org 的摘录(http://www.w3.org/TR/2000/NOTE-SOAP-20000508/).... 讲述了肥皂请求的接收和处理。
Here in second soap message you are sending an additional parent tag for you information, which may not be recognized by you server. If this tag is optional than there should be no problem at all, but if it is undesired then you should not use it. Below are the excerpts from W3.org(http://www.w3.org/TR/2000/NOTE-SOAP-20000508/) .... which tells about the receiving and processing of soap request.