如何修复'Element ns1:WS_PersonaGetActEmpresarial.Execute具有相对名称空间:ns1 =“ DGI_Modernizacion_Consolidado

时间:2019-04-10 19:50:30

标签: java soap axis2 ws-security genexus

我正在开发SOAP客户端,以使用WS-Security调用WebService。我使用axis2-1.6.2在Eclipse中生成de Stub。我要调用的WS的URL是:https://efactura.dgi.gub.uy:6475/efactura/ws_personaGetActEmpresarial?wsdl

这是XML:

<?xml version="1.0" encoding="UTF-8"?>

<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap11="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp200409="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsp200607="http://www.w3.org/2006/07/ws-policy" xmlns:ns0="DGI_Modernizacion_Consolidado" targetNamespace="DGI_Modernizacion_Consolidado">
<wsdl:types xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:schema>
<xsd:import schemaLocation="ws_personaGetActEmpresarial.xsd1.xsd" namespace="DGI_Modernizacion_Consolidado"/></xsd:schema></wsdl:types>
<wsdl:message name="WS_PersonaGetActEmpresarial.ExecuteSoapIn">
<wsdl:part name="parameters" element="xsns:WS_PersonaGetActEmpresarial.Execute" xmlns:xsns="DGI_Modernizacion_Consolidado"/></wsdl:message>
<wsdl:message name="WS_PersonaGetActEmpresarial.ExecuteSoapOut">
<wsdl:part name="parameters" element="xsns:WS_PersonaGetActEmpresarial.ExecuteResponse" xmlns:xsns="DGI_Modernizacion_Consolidado"/></wsdl:message>
<wsdl:portType name="WS_PersonaGetActEmpresarialSoapPort">
<wsdl:operation name="Execute">
<wsdl:input name="ExecuteRequest" message="ns0:WS_PersonaGetActEmpresarial.ExecuteSoapIn"/>
<wsdl:output name="ExecuteResponse" message="ns0:WS_PersonaGetActEmpresarial.ExecuteSoapOut"/></wsdl:operation></wsdl:portType>
<wsdl:binding name="WS_PersonaGetActEmpresarialSoapBinding" type="ns0:WS_PersonaGetActEmpresarialSoapPort">
<soap11:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="Execute">
<soap11:operation soapAction="DGI_Modernizacion_Consolidadoaction/AWS_PERSONAGETACTEMPRESARIAL.Execute" style="document"/>
<wsdl:input name="ExecuteRequest">
<soap11:body use="literal"/></wsdl:input>
<wsdl:output name="ExecuteResponse">
<soap11:body use="literal"/></wsdl:output></wsdl:operation></wsdl:binding>
<wsdl:service name="WS_PersonaGetActEmpresarial">
<wsp:PolicyReference URI="#policy0" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"/>
<wsdl:port name="WS_PersonaGetActEmpresarialSoapPort" binding="ns0:WS_PersonaGetActEmpresarialSoapBinding">
<soap11:address location="https://efactura.dgi.gub.uy:6475/efactura/ws_personaGetActEmpresarial"/></wsdl:port></wsdl:service>
<wsp:Policy wsu:Id="policy0" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
<wsp:ExactlyOne>
<wsp:All>
<dpe:summary xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200512" xmlns:dpe="http://www.datapower.com/extensions">

<dppolicy:domain xmlns:dppolicy="http://www.datapower.com/policy">
      http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200512
    </dppolicy:domain>

<description>
      Implements WS Security Policy 1.1 - support SignedParts
    </description>
  </dpe:summary>
<sp:SignedParts xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200512">

<sp:Body/>
      </sp:SignedParts></wsp:All></wsp:ExactlyOne></wsp:Policy></wsdl:definitions>

这是在Eclipse中以代码身份运行时的错误:

org.apache.axis2.AxisFault: Error in signature with X509Token
    at org.apache.rampart.handler.RampartSender.invoke(RampartSender.java:76)
    at org.apache.axis2.engine.Phase.invokeHandler(Phase.java:340)
    at org.apache.axis2.engine.Phase.invoke(Phase.java:313)
    at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:262)
    at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:427)
    at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:406)
    at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
    at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
    at dgi_modernizacion_consolidado.WS_PersonaGetActEmpresarialStub.execute(WS_PersonaGetActEmpresarialStub.java:188)
    at uy.gub.dgi.gx.DGIEfactura.executeExecute(DGIEfactura.java:368)
    at uy.gub.dgi.gx.DGIEfactura.ExecuteDGIWS(DGIEfactura.java:197)
    at uy.gub.dgi.gx.DGIEfactura.EXECUTE(DGIEfactura.java:171)
    at Executor.main(Executor.java:29)
Caused by: org.apache.rampart.RampartException: Error in signature with X509Token
    at org.apache.rampart.builder.AsymmetricBindingBuilder.doSignature(AsymmetricBindingBuilder.java:741)
    at org.apache.rampart.builder.AsymmetricBindingBuilder.doSignBeforeEncrypt(AsymmetricBindingBuilder.java:414)
    at org.apache.rampart.builder.AsymmetricBindingBuilder.build(AsymmetricBindingBuilder.java:90)
    at org.apache.rampart.MessageBuilder.build(MessageBuilder.java:147)
    at org.apache.rampart.handler.RampartSender.invoke(RampartSender.java:65)
    ... 12 more
Caused by: org.apache.ws.security.WSSecurityException: Signature creation failed
    at org.apache.ws.security.message.WSSecSignature.computeSignature(WSSecSignature.java:721)
    at org.apache.rampart.builder.AsymmetricBindingBuilder.doSignature(AsymmetricBindingBuilder.java:732)
    ... 16 more
Caused by: org.apache.xml.security.signature.ReferenceNotInitializedException: Element ns1:WS_PersonaGetActEmpresarial.Execute has a relative namespace: ns1="DGI_Modernizacion_Consolidado"
Original Exception was org.apache.xml.security.signature.ReferenceNotInitializedException: Element ns1:WS_PersonaGetActEmpresarial.Execute has a relative namespace: ns1="DGI_Modernizacion_Consolidado"
Original Exception was org.apache.xml.security.signature.XMLSignatureException: Element ns1:WS_PersonaGetActEmpresarial.Execute has a relative namespace: ns1="DGI_Modernizacion_Consolidado"
Original Exception was org.apache.xml.security.transforms.TransformationException: Element ns1:WS_PersonaGetActEmpresarial.Execute has a relative namespace: ns1="DGI_Modernizacion_Consolidado"
Original Exception was org.apache.xml.security.c14n.CanonicalizationException: Element ns1:WS_PersonaGetActEmpresarial.Execute has a relative namespace: ns1="DGI_Modernizacion_Consolidado"
Original Exception was org.apache.xml.security.c14n.CanonicalizationException: Element ns1:WS_PersonaGetActEmpresarial.Execute has a relative namespace: ns1="DGI_Modernizacion_Consolidado"
Original Exception was org.apache.xml.security.c14n.CanonicalizationException: Element ns1:WS_PersonaGetActEmpresarial.Execute has a relative namespace: ns1="DGI_Modernizacion_Consolidado"
    at org.apache.xml.security.signature.Reference.calculateDigest(Unknown Source)
    at org.apache.xml.security.signature.Reference.generateDigestValue(Unknown Source)
    at org.apache.xml.security.signature.Manifest.generateDigestValues(Unknown Source)
    at org.apache.xml.security.signature.XMLSignature.sign(Unknown Source)
    at org.apache.ws.security.message.WSSecSignature.computeSignature(WSSecSignature.java:717)
    ... 17 more

AxisFault -Error in signature with X509Token - Error in signature with X509Token -

这是我的Police.xml

    <?xml version="1.0" encoding="UTF-8"?>
<wsp:Policy wsu:Id="SigOnly" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
    <wsp:ExactlyOne>
        <wsp:All>
            <sp:AsymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
                <wsp:Policy>
                    <sp:InitiatorToken>
                        <wsp:Policy>
                            <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
                                <wsp:Policy>
                                    <sp:WssX509V3Token10/>
                                </wsp:Policy>
                            </sp:X509Token>
                        </wsp:Policy>
                    </sp:InitiatorToken>
                    <sp:RecipientToken>
                        <wsp:Policy>
                            <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never">
                                <wsp:Policy>
                                    <sp:WssX509V3Token10/>
                                </wsp:Policy>
                            </sp:X509Token>
                        </wsp:Policy>
                    </sp:RecipientToken>
                    <sp:AlgorithmSuite>
                        <wsp:Policy>
                            <sp:TripleDesRsa15/>
                        </wsp:Policy>
                    </sp:AlgorithmSuite>
                    <sp:Layout>
                        <wsp:Policy>
                            <sp:Strict/>
                        </wsp:Policy>
                    </sp:Layout>


                </wsp:Policy>
            </sp:AsymmetricBinding>
            <sp:Wss10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
                <wsp:Policy>
                    <sp:MustSupportRefKeyIdentifier/>
                    <sp:MustSupportRefIssuerSerial/>
                </wsp:Policy>
            </sp:Wss10>
            <sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
                <sp:Body/>
            </sp:SignedParts>
        </wsp:All>
    </wsp:ExactlyOne>
</wsp:Policy>

1 个答案:

答案 0 :(得分:0)

您可以附加policy.xml并使用Rampart 1.4。