6

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

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)

任何帮助将不胜感激。

4

5 回答 5

6

端点格式错误

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

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

正确的端点格式来设置构造函数

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

于 2015-01-15T13:08:19.963 回答
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.

于 2010-05-21T03:38:43.747 回答
0

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

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

希望有帮助。

于 2011-02-23T12:32:00.673 回答
0

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

我使用的 URLhttp://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)

于 2012-05-18T08:05:47.913 回答
0

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

于 2021-08-05T02:40:28.470 回答