当前位置:  开发笔记 > 前端 > 正文

SAXException:错误的信封标签

如何解决《SAXException:错误的信封标签》经验,为你挑选了1个好方法。

我正在尝试连接到通过Web服务客户端保护的Web服务https.Eclipse生成了一个基于存根的Web服务客户端,对我来说很好看.当我尝试从webservice调用方法时出现问题:

String a = (String)webservice.userProfileServices(xml);

我还使用以下SOAP标头:

esgGatewayPort = (new EsgGatewayLocator()).getesgGatewayPort();

//setting the authentication header
PrefixedQName name = new PrefixedQName("http://schemas.xmlsoap.org/ws/2002/07/secext","Security","wsse");
System.out.println("Setting headers for authentication");
org.apache.axis.message.SOAPHeaderElement sh = new org.apache.axis.message.SOAPHeaderElement(name);
SOAPElement sub;

try {

      String clntUserName="myUser";
      String clntPassword="myPassword";
      sub = sh.addChildElement("UsernameToken");
      SOAPElement element = sub.addChildElement("Username");
      element.addTextNode(clntUserName);
      element = sub.addChildElement("Password");
      element.addTextNode(clntPassword);
      ((org.apache.axis.client.Stub) esgGatewayPort).setHeader(sh);

} catch (SOAPException e) {

      e.printStackTrace();

}

我收到以下内容:

AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
 faultSubcode: 
 faultString: org.xml.sax.SAXException: Bad envelope tag:  HTML
 faultActor: 
 faultNode: 
 faultDetail: 
    {http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXException: Bad envelope tag:  HTML
    at org.apache.axis.message.EnvelopeBuilder.startElement(EnvelopeBuilder.java:71)
    at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1048)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at weblogic.xml.jaxp.WebLogicXMLReader.parse(WebLogicXMLReader.java:133)
    at weblogic.xml.jaxp.RegistryXMLReader.parse(RegistryXMLReader.java:153)
    at javax.xml.parsers.SAXParser.parse(Unknown Source)
    at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
    at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
    at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
    at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:796)
    at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
    at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
    at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
    at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
    at org.apache.axis.client.Call.invoke(Call.java:2767)
    at org.apache.axis.client.Call.invoke(Call.java:2443)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)

任何帮助将得到真正的赞赏.



1> Lucas Pires..:

端点格式错误

例如:http:// localhost:8080/YourService /

例如:http:// localhost:8080/YourService?wsdl

更正端点格式以设置构造函数

例如:http:// localhost:8080/YourService

推荐阅读
谢谢巷议
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有