SAXException: bad envelope tag
Asked Answered
Y

5

7

I'm trying to connect to a webservice https protected through a webservice client. Eclipse generated a stub based webservice client and looks nice to me. The problem comes when I try to call a method from the webservice:

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

I'm also using the following SOAP headers:

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();

}

I receive the following:

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)

Any help will be truly appreciated.

Yoshi answered 19/3, 2009 at 16:34 Comment(7)
What does your Soap Header (sh) look like when you call .setHeader ? This is not a valid header.Amias
This is my header code: esgGatewayPort = (new sgGatewayLocator()).getesgGatewayPort();Yoshi
PrefixedQName name = new PrefixedQName("schemas.xmlsoap.org/ws/2002/07/…); SOAPHeaderElement sh = new SOAPHeaderElement(name);Yoshi
SOAPElement sub; try {String clntUserName="u"; String clntPassword="p";Yoshi
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);Yoshi
After the setHeader looks to have the username and password. What the server is responding is HTML code :-(Yoshi
SOLVED!!! Well, Due Eclipse connects to Weblogic and creates the stubs, It defined an endpoint which was http. I just pointed out to https, got rid of the port and the ending ?WSDL.Yoshi
R
6

Wrong format of the endpoint

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

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

Correct endpoint format to set the constructor

Ex: http://localhost:8080/YourService

Recto answered 15/1, 2015 at 13:8 Comment(2)
It was a plaseure, KishoreRecto
May I know, why we need to call the service without "?wsdl" in WebSphere and with "?wsdl" in other servers ?Framboise
W
3

I resolved the problem in WAS (WebSphere Application Server), following http://www-01.ibm.com/support/docview.wss?uid=swg1PK54518. Applying the appropriate Fix Pack for your version of WAS resolved the issue.

Wellread answered 21/5, 2010 at 3:38 Comment(0)
T
0

The problem is probably that you are trying to bind to a https service using http. I had this problem when eclipse generated the stubs for me from a wsdl that was hosted on a https server.

Edit the generated files by eclipse that points to the server URL and it should connect correctly.

Hope that helps.

Trichinopoly answered 23/2, 2011 at 12:32 Comment(0)
A
0

In my case it got resolved after removing "/" from end of the URL in Axis (not Axis2)

The URL which I was using http://localhost:7000/myWS/
After changing it to http://localhost:7000/myWS worked fine!

Exception:
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)

Antecedents answered 18/5, 2012 at 8:5 Comment(0)
T
0

Main: org.xml.sax.SAXException: Bad envelope tag: script In our case error "Bad envelope tag: script" occurred because of user id got locked

Travers answered 5/8, 2021 at 2:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.