Java 创建 SAAJ 对象模型的问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24520325/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
problems creating SAAJ object model
提问by user468587
i tried to send a SOAP request in jquery to third party but always got this error:
我试图在 jquery 中向第三方发送 SOAP 请求,但总是收到此错误:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>Problems creating SAAJ object model</faultstring></soap:Fault></soap:Body></soap:Envelope>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>Problems creating SAAJ object model</faultstring></soap:Fault></soap:Body></soap:Envelope>
the way i did it is to pass couple of tokens to another function ,which create SOAP request based on those token. one of the token is a Html string like this:
我这样做的方法是将几个令牌传递给另一个函数,该函数根据这些令牌创建 SOAP 请求。令牌之一是这样的 Html 字符串:
<tr><td width="2" bgcolor="#ffffff"><\/td><td width="1" bgcolor="#d8dbe3"><\/td><td width="2" bgcolor="#ffffff"><\/td><td width="15" bgcolor="#f5f6f8"><\/td><td width="535" bgcolor="#f5f6f8"><table width="535" cellspacing="0" cellpadding="0" border="0" bgcolor="#f5f6f8"><tr><td width="80"><table width="80" height="96" bgcolor="#999999" cellspacing="0" cellpadding="0" border="0" align="center"><tr><td width="80" height="1" colspan="3"><\/td><\/tr><tr><td width="1" bgcolor="#999999"><\/td>....
whenever i added this token, the SOAP request failed. I tried to escaped this html string token, SOAP request succeeded but the whole string messed up with all the escaped characters and third party need this html string to render template, so i cannot sent the escaped version anyway. is there any way i can safely pass the html string without crashing the request?
每当我添加此令牌时,SOAP 请求都会失败。我试图转义这个 html 字符串令牌,SOAP 请求成功,但整个字符串与所有转义字符搞砸了,第三方需要这个 html 字符串来呈现模板,所以无论如何我都无法发送转义版本。有什么方法可以安全地传递 html 字符串而不会使请求崩溃?
回答by Dmitry Pod
Error "Problems creating SAAJ object model" usually occurs when soap-request cannot be parsed on the server side. In the log-file on the server you can see something like
错误“创建 SAAJ 对象模型的问题”通常发生在服务器端无法解析soap-request时。在服务器上的日志文件中,您可以看到类似
Caused by: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '>' (code 62) (expected a name start character)
at [row,col {unknown-source}]: [18,6]
You pass html tags to the soap envelope, so problems can be with escaping html-tags. It's a good practice to pass BASE64 string within soap-request for such kind of data
您将 html 标签传递给 soap 信封,因此转义 html-tags 可能会出现问题。对于此类数据,在soap-request 中传递BASE64 字符串是一种很好的做法
回答by Tangzhu
Please add a header like tihs "Content-type text/xml;charset=utf-8".
请添加一个标题,如 tihs "Content-type text/xml;charset=utf-8"。