javax.xml.stream.XMLStreamException:前缀重新绑定错误

时间:2018-06-22 06:26:02

标签: java soap soap-client webservice-client

错误:

var arr = [true, true, false, false, false, true, false];
var indexArray = [];
arr.forEach(function(value, index) {
    if (value) {
        indexArray.push(index);
    }
})
console.log(indexArray);

我有以下肥皂要求:

javax.xml.stream.XMLStreamException: prefix com has been already bound to http://myurl  Rebinding it to http://www.w3.org/2005/08/addressing is an error

我在标题中添加了授权令牌,如下所示:

<S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope" 
            xmlns:env="http://www.w3.org/2003/05/soap-envelope">
   <S:Header xmlns="http://www.w3.org/2005/08/addressing">
      <To></To>
      <Action></Action>
      <ReplyTo>
         <Address>http://www.w3.org/2005/08/addressing/anonymous</Address>
      </ReplyTo>
      <FaultTo>
         <Address>http://www.w3.org/2005/08/addressing/anonymous</Address>
      </FaultTo>
      <MessageID></MessageID>
   </S:Header>
   <S:Body xmlns="http://www.****.com/ns/2008/03/01/webservices/***/Cache_1" 
   xmlns:ns2="http://www.****.com/ns/2006/05/01/webservices/***/Common_1" 
   xmlns:ns3="http://www.***.com/ns/2006/05/01/webservices/***/Faults_1" 
   xmlns:ns4="http://www.****.com/ns/2006/05/01/webservices/***/QuotesCommon" 
   xmlns:ns5="http://www.***.com/ns/2006/05/01/webservices/***/Quotes_1" 
   xmlns:ns6="http://schemas.****.com/2003/10/Serialization/">
      ********
   </S:Body>
</S:Envelope>

处理程序中的Java代码,用于在标头中添加授权令牌

<S:Header xmlns="http://www.w3.org/2005/08/addressing">
      *****
      <com:Authorization xmlns:com="http://myurl">
         <com:ApplicationID>******</com:ApplicationID>
         <com:Token>*******</com:Token>
      </com:Authorization>
   </S:Header>

我遇到错误:

SOAPHeader header = envelope.getHeader();
SOAPElement authorization = header.addChildElement("com:Authorization");
                authorization.addNamespaceDeclaration("com", "http://myurl");  
                SOAPElement applicationID =  authorization.addChildElement("com:ApplicationID");
                applicationID.addTextNode("*******");
                SOAPElement token = authorization.addChildElement("com:Token");
                token.addTextNode("*****");

我在发送请求之前获得的Authorization标头标签在下面

javax.xml.ws.WebServiceException: javax.xml.stream.XMLStreamException: prefix com has been already bound to http://myurl. Rebinding it to http://www.w3.org/2005/08/addressing is an error

等待响应

1 个答案:

答案 0 :(得分:0)

我应用了以下代码,它对我有用

SOAPElement授权= header.addChildElement(“ Authorization”,“”,“ http://www.reuters.com/ns/2006/05/01/webservices/rkd/Common_1”);

这会给我以下的授权标题:

<Authorization xmlns="http://www.reuters.com/ns/2006/05/01/webservices/rkd/Common_1">
    <ApplicationID>********</ApplicationID>
   <Token>*******</Token>
</Authorization>