SAXException: bad envelope tag

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("","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 = sub.addChildElement("Password");
      ((org.apache.axis.client.Stub) esgGatewayPort).setHeader(sh);

} catch (SOAPException e) {



I receive the following:

 faultCode: {}Server.userException
 faultString: org.xml.sax.SAXException: Bad envelope tag:  HTML
    {}stackTrace:org.xml.sax.SAXException: Bad envelope tag:  HTML
    at org.apache.axis.message.EnvelopeBuilder.startElement(
    at org.apache.axis.encoding.DeserializationContext.startElement(
    at Source)
    at Source)
    at$NSContentDriver.scanRootElementHook(Unknown Source)
    at$ Source)
    at$ Source)
    at Source)
    at Source)
    at Source)
    at Source)
    at Source)
    at Source)
    at Source)
    at$JAXPSAXParser.parse(Unknown Source)
    at weblogic.xml.jaxp.WebLogicXMLReader.parse(
    at weblogic.xml.jaxp.RegistryXMLReader.parse(
    at javax.xml.parsers.SAXParser.parse(Unknown Source)
    at org.apache.axis.encoding.DeserializationContext.parse(
    at org.apache.axis.SOAPPart.getAsSOAPEnvelope(
    at org.apache.axis.Message.getSOAPEnvelope(
    at org.apache.axis.transport.http.HTTPSender.readFromSocket(
    at org.apache.axis.transport.http.HTTPSender.invoke(
    at org.apache.axis.strategies.InvocationStrategy.visit(
    at org.apache.axis.SimpleChain.doVisiting(
    at org.apache.axis.SimpleChain.invoke(
    at org.apache.axis.client.AxisClient.invoke(
    at org.apache.axis.client.Call.invokeEngine(
    at org.apache.axis.client.Call.invoke(
    at org.apache.axis.client.Call.invoke(
    at org.apache.axis.client.Call.invoke(
    at org.apache.axis.client.Call.invoke(

Any help will be truly appreciated.

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

I resolved the problem in WAS (WebSphere Application Server), following Applying the appropriate Fix Pack for your version of WAS resolved the issue.

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.

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!

Main: org.xml.sax.SAXException: Bad envelope tag: table
at org.apache.axis.AxisFault.makeFault(
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(
at org.apache.axis.Message.getSOAPEnvelope(
at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(
at org.apache.axis.client.AxisClient.invoke(

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

Leave a Comment