SOAP Java Axis错误:MustUnderstand不被理解

时间:2016-06-03 14:33:41

标签: java soap axis

我们必须让WS Client使用远程服务。使用WSS $ J安全配置创建ClientHandler,使用Axis从eclipse生成WSClient。我收到了这个错误,没有信息可以找到它。有什么想法吗?

AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}MustUnderstand
  faultSubcode: 
 faultString: Did not understand "MustUnderstand" header(s):    {http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-     1.0.xsd}Security
 faultActor: 
 faultNode: 
 faultDetail: 
{http://xml.apache.org/axis/}stackTrace:
at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:96)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
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)
at uy.gub.dgi.WS_eFacturaSoapBindingStub.EFACRECEPCIONSOBRE(WS_eFacturaSoapBindingStub.java:306)
at com.justinfact.web.ws.EFacturaClient.main(EFacturaClient.java:51)

{http://xml.apache.org/axis/}hostname:jirazazabal-pc

Did not understand "MustUnderstand" header(s):{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}Security
at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:96)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
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)
at uy.gub.dgi.WS_eFacturaSoapBindingStub.EFACRECEPCIONSOBRE(WS_eFacturaSoapBindingStub.java:306)
at com.justinfact.web.ws.EFacturaClient.main(EFacturaClient.java:51)
AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}MustUnderstand
 faultSubcode: 
 faultString: Did not understand "MustUnderstand" header(s):    {http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext- 1.0.xsd}Security
 faultActor: 
 faultNode: 
 faultDetail: 
{http://xml.apache.org/axis/}stackTrace:
at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:96)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
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)
at uy.gub.dgi.WS_eFacturaSoapBindingStub.EFACRECEPCIONSOBRE(WS_eFacturaSoapBindingStub.java:306)
at com.justinfact.web.ws.EFacturaClient.main(EFacturaClient.java:51)

{http://xml.apache.org/axis/}hostname:jirazazabal-pc

Did not understand "MustUnderstand" header(s):{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}Security
at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:96)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
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)
at uy.gub.dgi.WS_eFacturaSoapBindingStub.EFACRECEPCIONSOBRE(WS_eFacturaSoapBindingStub.java:306)
at com.justinfact.web.ws.EFacturaClient.main(EFacturaClient.java:51)

SOAP请求似乎没问题,但是收到此错误。 SOAP的标题就像:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
              mlns:xsd="http://www.w3.org/2001/XMLSchema" 
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
    <wsse:Security soapenv:mustUnderstand="1" 
                   xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" 
                   xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <wsse:BinarySecurityToken EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" 
                              ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" 
                              wsu:Id="X509-47B7B0AB8DD8408E9814649487947394">
        MIIFhDCCA2ygAwIBAgIQUR762xXMDeJWWLNGuZSuszANBgkqhkiG9w0BAQUFADB6MQswCQYDVQQGEwJVWTErMCkGA1UECgwiQURNSU5JU1RSQUNJT04gTkFDSU9OQUwgREUgQ09SUkVPUzEfMB0GA1UECwwWU0VSVklDSU9
        TIEVMRUNUUk9OSUNPUzEdMBsGA1UEAwwUQ29ycmVvIFVydWd1YXlvIC0gQ0EwHhcNMTUxMTI3MTk0NzE4WhcNMTYxMTI3MTk0NzE4WjCBmzEmMCQGCSqGSIb3DQEJARYXdml0YW1pbmljby4wNUBnbWFpbC5jb20xEzARBg
        NVBAoMClZJVEFNSU5JQ08xEzARBgNVBAgMCk1vbnRldmlkZW8xCzAJBgNVBAYTAlVZMRgwFgYDVQQFEw9SVUMyMTUyMTcxOTAwMTUxIDAeBgNVBAMMF1ZJTkFMUyBJVkFOSUNIIExFT05BUkRPMIGfMA0GCSqGSIb3DQEBA
        QUAA4GNADCBiQKBgQC6LdZWhEJaqiFaZb1VG+o7aEckJT4hkFfTj1FqfBzbS/Ug4uXcESdmOahQPVCpJcG8jgW6HuCO1dlQ9P0Qwsxk+zjCHe+Bm4+lnFQfcn1ClMvkGJzAxE/HJbBXkr1WD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5bFXW6YjeTNBDm60o4bTTFLLbfO1LZIM8JpubIzsE7+c4Ph4FTuW/HxOE8F8HkLk0X1bxf4o1Did3pDjXDlIafi66//F7z5gf8xJeams5/w7ToikOmW+pjpLolOT64RvY0WjQs5/FdEXu+7i
        vjrOk5xRzxdnKLIr9vUOYyFfE0627yA2mS8+uUWy41BISdsXI6z
    </wsse:BinarySecurityToken>

1 个答案:

答案 0 :(得分:3)

我之前遇到过这样的问题,我通过做这样的事情来解决这个问题:

   public String callWS(String arg1 ,String arg2){
org.apache.axis.client.Call _call = createCall();
        _call.setOperation(_operations[0]);
        _call.setUseSOAPAction(true);
        _call.setSOAPActionURI("web service URL");
        _call.setEncodingStyle(null);
        _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
        _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
        //pay attention to line below
        _call.setProperty(org.apache.axis.client.Call.CHECK_MUST_UNDERSTAND, Boolean.FALSE);
        _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP12_CONSTANTS);
        _call.setOperationName(new javax.xml.namespace.QName("http://zzzzz", "xxxx"));
        setRequestHeaders(_call);
        setAttachments(_call);

        Object _resp = _call.invoke(new Object[] {arg1,arg2});
        return (String) org.apache.axis.utils.JavaUtils.convert(_resp, String.class);

}

注意这一行:

_call.setProperty(org.apache.axis.client.Call.CHECK_MUST_UNDERSTAND, Boolean.FALSE);

希望它适合你:)