SAXException:错误的信封标签

时间:2009-03-19 16:34:34

标签: html soap tags envelope

我正在尝试连接到通过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)

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

5 个答案:

答案 0 :(得分:5)

端点格式错误

Ex:http://localhost:8080/YourService/

Ex:http://localhost:8080/YourService?wsdl

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

Ex:http://localhost:8080/YourService

答案 1 :(得分:3)

我在http://www-01.ibm.com/support/docview.wss?uid=swg1PK54518之后解决了WAS(WebSphere Application Server)中的问题。为您的WAS版本应用适当的Fix Pack解决了这个问题。

答案 2 :(得分:0)

问题可能是您尝试使用http绑定到https服务。当eclipse从https服务器上托管的wsdl为我生成存根时,我遇到了这个问题。

通过指向服务器URL的eclipse编辑生成的文件,它应该正确连接。

希望有所帮助。

答案 3 :(得分:0)

在我的情况下,从Axis(而不是Axis2)中的URL末尾删除“/”后它得到解决

我使用的网址http://localhost:7000/myWS/
将其更改为http://localhost:7000/myWS后工作正常!

例外:
Main: org.xml.sax.SAXException: Bad envelope tag: table at org.apache.axis.AxisFault.makeFault(AxisFault.java:101) at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:701) at org.apache.axis.Message.getSOAPEnvelope(Message.java:435) at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62) at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)

答案 4 :(得分:0)

主要:org.xml.sax.SAXException:错误的信封标签:脚本 在我们的案例中,由于用户 ID 被锁定,因此发生了错误“信封标签错误:脚本”