How to programatically construct a SOAP request based on WSDL and Request XML










0















There's a webservice that when called from SOAPUI works fine.



I have a webservice client, that is returning an error when mashalling a SoapBodyElement as indicated bellow. ( was said that it was working before =D )
Inspecting the code, it comes that when invoking the service, its receiving a SoapBodyElement as a parameter, and that's where the service fails.



From WSDL I see the the type is anyType so the requestbody or part (i'm confused here) should be constructed and passed as an argument.



The question is, how can I generate the the args properly based on the WSDL and the knowledge about the proper functioning request?



WebService Call



public void test() throws SOAPException 
CCCaminhaoProxy proxyCCCaminhao = new CCCaminhaoProxy();

DigestBO digest = BOFactory.getDigestBO();

SOAPMessage message = MessageFactory.newInstance().createMessage();
SOAPPart soapPart = message.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
SOAPBody body = envelope.getBody();

Name transicao = envelope.createName("Transicao");
Name idTransacao = envelope.createName("idTransacao");
Name numeroAgendamento = envelope.createName("numeroAgendamento");
Name placaCarreta = envelope.createName("placaCarreta");
Name compartimento = envelope.createName("compartimento");
Name faseCarregamento = envelope.createName("faseCarregamento");

SOAPBodyElement root = body.addBodyElement(transicao);

Random r = new Random();
String vIdTransacao = String.valueOf(Math.abs(r.nextLong()));

root.addAttribute(idTransacao, vIdTransacao);
root.addAttribute(numeroAgendamento, "1035622");
root.addAttribute(placaCarreta, "KNX0002");
root.addAttribute(compartimento, "01");
root.addAttribute(faseCarregamento, "01");

SOAPElement soapElement;
try
soapElement = (SOAPElement) proxyCCCaminhao.digest(root);
digest.tratarRetornoDigest(soapElement);
catch (ErroComunicacaoCCCaminhaoException e)
logger.error(null, e);




ERROR



com.domain.controleacesso.integracao.cccaminhao.ErroComunicacaoCCCaminhaoException: java.rmi.RemoteException: web service invoke failed: javax.xml.soap.SOAPException: failed to serialize class java.lang.Objectweblogic.xml.schema.binding.SerializationException: type mapping lookup failure on class=class weblogic.xml.saaj.SOAPElementImpl TypeMapping=TYPEMAPPING SIZE=3
ENTRY 1:
class: java.lang.Object
xsd_type: ['http://www.w3.org/2001/XMLSchema']:xsd:anyType
ser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d02f37
deser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d02fa3
ENTRY 2:
class: java.lang.Object
xsd_type: ['http://xml.domain.biz/2010/scoa:changestate']:stns:digestReturn
ser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d031c4
deser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d0321d
ENTRY 3:
class: java.lang.Object
xsd_type: ['http://xml.domain.biz/2010/scoa:changestate']:stns:digest
ser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d3dff6
deser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d3e04f
; nested exception is:
javax.xml.soap.SOAPException: failed to serialize class java.lang.Objectweblogic.xml.schema.binding.SerializationException: type mapping lookup failure on class=class weblogic.xml.saaj.SOAPElementImpl TypeMapping=TYPEMAPPING SIZE=3
ENTRY 1:
class: java.lang.Object
xsd_type: ['http://www.w3.org/2001/XMLSchema']:xsd:anyType
ser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d02f37
deser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d02fa3
ENTRY 2:
class: java.lang.Object
xsd_type: ['http://xml.domain.biz/2010/scoa:changestate']:stns:digestReturn
ser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d031c4
deser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d0321d
ENTRY 3:
class: java.lang.Object
xsd_type: ['http://xml.domain.biz/2010/scoa:changestate']:stns:digest
ser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d3dff6
deser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d3e04f


Request (that works when sending through SOAPUI)



<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:scoa="http://xml.domain.biz/2010/scoa:changestate" xmlns:chan="http://xml.domain.biz/2010/scoa/changestate">
<soapenv:Header/>
<soapenv:Body>
<scoa:digest>
<Transicao idTransacao="1541772100700" numeroAgendamento="1035622" placaCarreta="KNX0002" compartimento="01" faseCarregamento="01"/>
</scoa:digest>
</soapenv:Body>
</soapenv:Envelope>


WSDL



<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:impl="http://xml.domain.biz/2010/scoa:changestate"
xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:intf="http://xml.domain.biz/2010/scoa:changestate"
targetNamespace="http://xml.domain.biz/2010/scoa:changestate">
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://xml.domain.biz/2010/scoa:changestate">
<element name="digest" type="xsd:anyType"></element>
<element name="digestReturn" type="xsd:anyType"></element>
</schema>
</wsdl:types>
<wsdl:message name="digestRequest">
<wsdl:part element="impl:digest" name="part"></wsdl:part>
</wsdl:message>
<wsdl:message name="digestResponse">
<wsdl:part element="impl:digestReturn" name="digestReturn"></wsdl:part>
</wsdl:message>
<wsdl:portType name="ChangeStateWS">
<wsdl:operation name="digest">
<wsdl:input message="impl:digestRequest" name="digestRequest"></wsdl:input>
<wsdl:output message="impl:digestResponse" name="digestResponse"></wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ChangeState.svcSoapBinding" type="impl:ChangeStateWS">
<wsdlsoap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"></wsdlsoap:binding>
<wsdl:operation name="digest">
<wsdlsoap:operation soapAction=""></wsdlsoap:operation>
<wsdl:input name="digestRequest">
<wsdlsoap:body use="literal"></wsdlsoap:body>
</wsdl:input>
<wsdl:output name="digestResponse">
<wsdlsoap:body use="literal"></wsdlsoap:body>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ChangeStateWSService">
<wsdl:port name="ChangeState.svc" binding="impl:ChangeState.svcSoapBinding">
<wsdlsoap:address
location="http://domain.ltd/scoa/services/ChangeState.svc"></wsdlsoap:address>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>


type-mappint



<?xml version="1.0" encoding="UTF-8"?>
<wsdd:type-mapping xmlns:wsdd="http://www.bea.com/servers/wls70"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<wsdd:type-mapping-entry class-name="java.lang.Object"
type="xsd:anyType"
serializer="weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec"
deserializer="weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec">
</wsdd:type-mapping-entry>
<wsdd:type-mapping-entry xmlns:stns="http://xml.domain.biz/2010/scoa:changestate"
class-name="java.lang.Object"
type="stns:digestReturn"
serializer="weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec"
deserializer="weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec">
</wsdd:type-mapping-entry>
<wsdd:type-mapping-entry xmlns:stns="http://xml.domain.biz/2010/scoa:changestate"
class-name="java.lang.Object"
type="stns:digest"
serializer="weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec"
deserializer="weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec">
</wsdd:type-mapping-entry>
</wsdd:type-mapping>









share|improve this question




























    0















    There's a webservice that when called from SOAPUI works fine.



    I have a webservice client, that is returning an error when mashalling a SoapBodyElement as indicated bellow. ( was said that it was working before =D )
    Inspecting the code, it comes that when invoking the service, its receiving a SoapBodyElement as a parameter, and that's where the service fails.



    From WSDL I see the the type is anyType so the requestbody or part (i'm confused here) should be constructed and passed as an argument.



    The question is, how can I generate the the args properly based on the WSDL and the knowledge about the proper functioning request?



    WebService Call



    public void test() throws SOAPException 
    CCCaminhaoProxy proxyCCCaminhao = new CCCaminhaoProxy();

    DigestBO digest = BOFactory.getDigestBO();

    SOAPMessage message = MessageFactory.newInstance().createMessage();
    SOAPPart soapPart = message.getSOAPPart();
    SOAPEnvelope envelope = soapPart.getEnvelope();
    SOAPBody body = envelope.getBody();

    Name transicao = envelope.createName("Transicao");
    Name idTransacao = envelope.createName("idTransacao");
    Name numeroAgendamento = envelope.createName("numeroAgendamento");
    Name placaCarreta = envelope.createName("placaCarreta");
    Name compartimento = envelope.createName("compartimento");
    Name faseCarregamento = envelope.createName("faseCarregamento");

    SOAPBodyElement root = body.addBodyElement(transicao);

    Random r = new Random();
    String vIdTransacao = String.valueOf(Math.abs(r.nextLong()));

    root.addAttribute(idTransacao, vIdTransacao);
    root.addAttribute(numeroAgendamento, "1035622");
    root.addAttribute(placaCarreta, "KNX0002");
    root.addAttribute(compartimento, "01");
    root.addAttribute(faseCarregamento, "01");

    SOAPElement soapElement;
    try
    soapElement = (SOAPElement) proxyCCCaminhao.digest(root);
    digest.tratarRetornoDigest(soapElement);
    catch (ErroComunicacaoCCCaminhaoException e)
    logger.error(null, e);




    ERROR



    com.domain.controleacesso.integracao.cccaminhao.ErroComunicacaoCCCaminhaoException: java.rmi.RemoteException: web service invoke failed: javax.xml.soap.SOAPException: failed to serialize class java.lang.Objectweblogic.xml.schema.binding.SerializationException: type mapping lookup failure on class=class weblogic.xml.saaj.SOAPElementImpl TypeMapping=TYPEMAPPING SIZE=3
    ENTRY 1:
    class: java.lang.Object
    xsd_type: ['http://www.w3.org/2001/XMLSchema']:xsd:anyType
    ser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d02f37
    deser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d02fa3
    ENTRY 2:
    class: java.lang.Object
    xsd_type: ['http://xml.domain.biz/2010/scoa:changestate']:stns:digestReturn
    ser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d031c4
    deser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d0321d
    ENTRY 3:
    class: java.lang.Object
    xsd_type: ['http://xml.domain.biz/2010/scoa:changestate']:stns:digest
    ser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d3dff6
    deser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d3e04f
    ; nested exception is:
    javax.xml.soap.SOAPException: failed to serialize class java.lang.Objectweblogic.xml.schema.binding.SerializationException: type mapping lookup failure on class=class weblogic.xml.saaj.SOAPElementImpl TypeMapping=TYPEMAPPING SIZE=3
    ENTRY 1:
    class: java.lang.Object
    xsd_type: ['http://www.w3.org/2001/XMLSchema']:xsd:anyType
    ser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d02f37
    deser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d02fa3
    ENTRY 2:
    class: java.lang.Object
    xsd_type: ['http://xml.domain.biz/2010/scoa:changestate']:stns:digestReturn
    ser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d031c4
    deser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d0321d
    ENTRY 3:
    class: java.lang.Object
    xsd_type: ['http://xml.domain.biz/2010/scoa:changestate']:stns:digest
    ser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d3dff6
    deser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d3e04f


    Request (that works when sending through SOAPUI)



    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:scoa="http://xml.domain.biz/2010/scoa:changestate" xmlns:chan="http://xml.domain.biz/2010/scoa/changestate">
    <soapenv:Header/>
    <soapenv:Body>
    <scoa:digest>
    <Transicao idTransacao="1541772100700" numeroAgendamento="1035622" placaCarreta="KNX0002" compartimento="01" faseCarregamento="01"/>
    </scoa:digest>
    </soapenv:Body>
    </soapenv:Envelope>


    WSDL



    <?xml version="1.0" encoding="UTF-8"?>
    <wsdl:definitions xmlns:impl="http://xml.domain.biz/2010/scoa:changestate"
    xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:intf="http://xml.domain.biz/2010/scoa:changestate"
    targetNamespace="http://xml.domain.biz/2010/scoa:changestate">
    <wsdl:types>
    <schema xmlns="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://xml.domain.biz/2010/scoa:changestate">
    <element name="digest" type="xsd:anyType"></element>
    <element name="digestReturn" type="xsd:anyType"></element>
    </schema>
    </wsdl:types>
    <wsdl:message name="digestRequest">
    <wsdl:part element="impl:digest" name="part"></wsdl:part>
    </wsdl:message>
    <wsdl:message name="digestResponse">
    <wsdl:part element="impl:digestReturn" name="digestReturn"></wsdl:part>
    </wsdl:message>
    <wsdl:portType name="ChangeStateWS">
    <wsdl:operation name="digest">
    <wsdl:input message="impl:digestRequest" name="digestRequest"></wsdl:input>
    <wsdl:output message="impl:digestResponse" name="digestResponse"></wsdl:output>
    </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="ChangeState.svcSoapBinding" type="impl:ChangeStateWS">
    <wsdlsoap:binding style="document"
    transport="http://schemas.xmlsoap.org/soap/http"></wsdlsoap:binding>
    <wsdl:operation name="digest">
    <wsdlsoap:operation soapAction=""></wsdlsoap:operation>
    <wsdl:input name="digestRequest">
    <wsdlsoap:body use="literal"></wsdlsoap:body>
    </wsdl:input>
    <wsdl:output name="digestResponse">
    <wsdlsoap:body use="literal"></wsdlsoap:body>
    </wsdl:output>
    </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="ChangeStateWSService">
    <wsdl:port name="ChangeState.svc" binding="impl:ChangeState.svcSoapBinding">
    <wsdlsoap:address
    location="http://domain.ltd/scoa/services/ChangeState.svc"></wsdlsoap:address>
    </wsdl:port>
    </wsdl:service>
    </wsdl:definitions>


    type-mappint



    <?xml version="1.0" encoding="UTF-8"?>
    <wsdd:type-mapping xmlns:wsdd="http://www.bea.com/servers/wls70"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
    <wsdd:type-mapping-entry class-name="java.lang.Object"
    type="xsd:anyType"
    serializer="weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec"
    deserializer="weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec">
    </wsdd:type-mapping-entry>
    <wsdd:type-mapping-entry xmlns:stns="http://xml.domain.biz/2010/scoa:changestate"
    class-name="java.lang.Object"
    type="stns:digestReturn"
    serializer="weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec"
    deserializer="weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec">
    </wsdd:type-mapping-entry>
    <wsdd:type-mapping-entry xmlns:stns="http://xml.domain.biz/2010/scoa:changestate"
    class-name="java.lang.Object"
    type="stns:digest"
    serializer="weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec"
    deserializer="weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec">
    </wsdd:type-mapping-entry>
    </wsdd:type-mapping>









    share|improve this question


























      0












      0








      0








      There's a webservice that when called from SOAPUI works fine.



      I have a webservice client, that is returning an error when mashalling a SoapBodyElement as indicated bellow. ( was said that it was working before =D )
      Inspecting the code, it comes that when invoking the service, its receiving a SoapBodyElement as a parameter, and that's where the service fails.



      From WSDL I see the the type is anyType so the requestbody or part (i'm confused here) should be constructed and passed as an argument.



      The question is, how can I generate the the args properly based on the WSDL and the knowledge about the proper functioning request?



      WebService Call



      public void test() throws SOAPException 
      CCCaminhaoProxy proxyCCCaminhao = new CCCaminhaoProxy();

      DigestBO digest = BOFactory.getDigestBO();

      SOAPMessage message = MessageFactory.newInstance().createMessage();
      SOAPPart soapPart = message.getSOAPPart();
      SOAPEnvelope envelope = soapPart.getEnvelope();
      SOAPBody body = envelope.getBody();

      Name transicao = envelope.createName("Transicao");
      Name idTransacao = envelope.createName("idTransacao");
      Name numeroAgendamento = envelope.createName("numeroAgendamento");
      Name placaCarreta = envelope.createName("placaCarreta");
      Name compartimento = envelope.createName("compartimento");
      Name faseCarregamento = envelope.createName("faseCarregamento");

      SOAPBodyElement root = body.addBodyElement(transicao);

      Random r = new Random();
      String vIdTransacao = String.valueOf(Math.abs(r.nextLong()));

      root.addAttribute(idTransacao, vIdTransacao);
      root.addAttribute(numeroAgendamento, "1035622");
      root.addAttribute(placaCarreta, "KNX0002");
      root.addAttribute(compartimento, "01");
      root.addAttribute(faseCarregamento, "01");

      SOAPElement soapElement;
      try
      soapElement = (SOAPElement) proxyCCCaminhao.digest(root);
      digest.tratarRetornoDigest(soapElement);
      catch (ErroComunicacaoCCCaminhaoException e)
      logger.error(null, e);




      ERROR



      com.domain.controleacesso.integracao.cccaminhao.ErroComunicacaoCCCaminhaoException: java.rmi.RemoteException: web service invoke failed: javax.xml.soap.SOAPException: failed to serialize class java.lang.Objectweblogic.xml.schema.binding.SerializationException: type mapping lookup failure on class=class weblogic.xml.saaj.SOAPElementImpl TypeMapping=TYPEMAPPING SIZE=3
      ENTRY 1:
      class: java.lang.Object
      xsd_type: ['http://www.w3.org/2001/XMLSchema']:xsd:anyType
      ser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d02f37
      deser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d02fa3
      ENTRY 2:
      class: java.lang.Object
      xsd_type: ['http://xml.domain.biz/2010/scoa:changestate']:stns:digestReturn
      ser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d031c4
      deser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d0321d
      ENTRY 3:
      class: java.lang.Object
      xsd_type: ['http://xml.domain.biz/2010/scoa:changestate']:stns:digest
      ser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d3dff6
      deser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d3e04f
      ; nested exception is:
      javax.xml.soap.SOAPException: failed to serialize class java.lang.Objectweblogic.xml.schema.binding.SerializationException: type mapping lookup failure on class=class weblogic.xml.saaj.SOAPElementImpl TypeMapping=TYPEMAPPING SIZE=3
      ENTRY 1:
      class: java.lang.Object
      xsd_type: ['http://www.w3.org/2001/XMLSchema']:xsd:anyType
      ser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d02f37
      deser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d02fa3
      ENTRY 2:
      class: java.lang.Object
      xsd_type: ['http://xml.domain.biz/2010/scoa:changestate']:stns:digestReturn
      ser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d031c4
      deser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d0321d
      ENTRY 3:
      class: java.lang.Object
      xsd_type: ['http://xml.domain.biz/2010/scoa:changestate']:stns:digest
      ser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d3dff6
      deser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d3e04f


      Request (that works when sending through SOAPUI)



      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:scoa="http://xml.domain.biz/2010/scoa:changestate" xmlns:chan="http://xml.domain.biz/2010/scoa/changestate">
      <soapenv:Header/>
      <soapenv:Body>
      <scoa:digest>
      <Transicao idTransacao="1541772100700" numeroAgendamento="1035622" placaCarreta="KNX0002" compartimento="01" faseCarregamento="01"/>
      </scoa:digest>
      </soapenv:Body>
      </soapenv:Envelope>


      WSDL



      <?xml version="1.0" encoding="UTF-8"?>
      <wsdl:definitions xmlns:impl="http://xml.domain.biz/2010/scoa:changestate"
      xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
      xmlns:intf="http://xml.domain.biz/2010/scoa:changestate"
      targetNamespace="http://xml.domain.biz/2010/scoa:changestate">
      <wsdl:types>
      <schema xmlns="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://xml.domain.biz/2010/scoa:changestate">
      <element name="digest" type="xsd:anyType"></element>
      <element name="digestReturn" type="xsd:anyType"></element>
      </schema>
      </wsdl:types>
      <wsdl:message name="digestRequest">
      <wsdl:part element="impl:digest" name="part"></wsdl:part>
      </wsdl:message>
      <wsdl:message name="digestResponse">
      <wsdl:part element="impl:digestReturn" name="digestReturn"></wsdl:part>
      </wsdl:message>
      <wsdl:portType name="ChangeStateWS">
      <wsdl:operation name="digest">
      <wsdl:input message="impl:digestRequest" name="digestRequest"></wsdl:input>
      <wsdl:output message="impl:digestResponse" name="digestResponse"></wsdl:output>
      </wsdl:operation>
      </wsdl:portType>
      <wsdl:binding name="ChangeState.svcSoapBinding" type="impl:ChangeStateWS">
      <wsdlsoap:binding style="document"
      transport="http://schemas.xmlsoap.org/soap/http"></wsdlsoap:binding>
      <wsdl:operation name="digest">
      <wsdlsoap:operation soapAction=""></wsdlsoap:operation>
      <wsdl:input name="digestRequest">
      <wsdlsoap:body use="literal"></wsdlsoap:body>
      </wsdl:input>
      <wsdl:output name="digestResponse">
      <wsdlsoap:body use="literal"></wsdlsoap:body>
      </wsdl:output>
      </wsdl:operation>
      </wsdl:binding>
      <wsdl:service name="ChangeStateWSService">
      <wsdl:port name="ChangeState.svc" binding="impl:ChangeState.svcSoapBinding">
      <wsdlsoap:address
      location="http://domain.ltd/scoa/services/ChangeState.svc"></wsdlsoap:address>
      </wsdl:port>
      </wsdl:service>
      </wsdl:definitions>


      type-mappint



      <?xml version="1.0" encoding="UTF-8"?>
      <wsdd:type-mapping xmlns:wsdd="http://www.bea.com/servers/wls70"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
      <wsdd:type-mapping-entry class-name="java.lang.Object"
      type="xsd:anyType"
      serializer="weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec"
      deserializer="weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec">
      </wsdd:type-mapping-entry>
      <wsdd:type-mapping-entry xmlns:stns="http://xml.domain.biz/2010/scoa:changestate"
      class-name="java.lang.Object"
      type="stns:digestReturn"
      serializer="weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec"
      deserializer="weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec">
      </wsdd:type-mapping-entry>
      <wsdd:type-mapping-entry xmlns:stns="http://xml.domain.biz/2010/scoa:changestate"
      class-name="java.lang.Object"
      type="stns:digest"
      serializer="weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec"
      deserializer="weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec">
      </wsdd:type-mapping-entry>
      </wsdd:type-mapping>









      share|improve this question
















      There's a webservice that when called from SOAPUI works fine.



      I have a webservice client, that is returning an error when mashalling a SoapBodyElement as indicated bellow. ( was said that it was working before =D )
      Inspecting the code, it comes that when invoking the service, its receiving a SoapBodyElement as a parameter, and that's where the service fails.



      From WSDL I see the the type is anyType so the requestbody or part (i'm confused here) should be constructed and passed as an argument.



      The question is, how can I generate the the args properly based on the WSDL and the knowledge about the proper functioning request?



      WebService Call



      public void test() throws SOAPException 
      CCCaminhaoProxy proxyCCCaminhao = new CCCaminhaoProxy();

      DigestBO digest = BOFactory.getDigestBO();

      SOAPMessage message = MessageFactory.newInstance().createMessage();
      SOAPPart soapPart = message.getSOAPPart();
      SOAPEnvelope envelope = soapPart.getEnvelope();
      SOAPBody body = envelope.getBody();

      Name transicao = envelope.createName("Transicao");
      Name idTransacao = envelope.createName("idTransacao");
      Name numeroAgendamento = envelope.createName("numeroAgendamento");
      Name placaCarreta = envelope.createName("placaCarreta");
      Name compartimento = envelope.createName("compartimento");
      Name faseCarregamento = envelope.createName("faseCarregamento");

      SOAPBodyElement root = body.addBodyElement(transicao);

      Random r = new Random();
      String vIdTransacao = String.valueOf(Math.abs(r.nextLong()));

      root.addAttribute(idTransacao, vIdTransacao);
      root.addAttribute(numeroAgendamento, "1035622");
      root.addAttribute(placaCarreta, "KNX0002");
      root.addAttribute(compartimento, "01");
      root.addAttribute(faseCarregamento, "01");

      SOAPElement soapElement;
      try
      soapElement = (SOAPElement) proxyCCCaminhao.digest(root);
      digest.tratarRetornoDigest(soapElement);
      catch (ErroComunicacaoCCCaminhaoException e)
      logger.error(null, e);




      ERROR



      com.domain.controleacesso.integracao.cccaminhao.ErroComunicacaoCCCaminhaoException: java.rmi.RemoteException: web service invoke failed: javax.xml.soap.SOAPException: failed to serialize class java.lang.Objectweblogic.xml.schema.binding.SerializationException: type mapping lookup failure on class=class weblogic.xml.saaj.SOAPElementImpl TypeMapping=TYPEMAPPING SIZE=3
      ENTRY 1:
      class: java.lang.Object
      xsd_type: ['http://www.w3.org/2001/XMLSchema']:xsd:anyType
      ser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d02f37
      deser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d02fa3
      ENTRY 2:
      class: java.lang.Object
      xsd_type: ['http://xml.domain.biz/2010/scoa:changestate']:stns:digestReturn
      ser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d031c4
      deser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d0321d
      ENTRY 3:
      class: java.lang.Object
      xsd_type: ['http://xml.domain.biz/2010/scoa:changestate']:stns:digest
      ser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d3dff6
      deser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d3e04f
      ; nested exception is:
      javax.xml.soap.SOAPException: failed to serialize class java.lang.Objectweblogic.xml.schema.binding.SerializationException: type mapping lookup failure on class=class weblogic.xml.saaj.SOAPElementImpl TypeMapping=TYPEMAPPING SIZE=3
      ENTRY 1:
      class: java.lang.Object
      xsd_type: ['http://www.w3.org/2001/XMLSchema']:xsd:anyType
      ser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d02f37
      deser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d02fa3
      ENTRY 2:
      class: java.lang.Object
      xsd_type: ['http://xml.domain.biz/2010/scoa:changestate']:stns:digestReturn
      ser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d031c4
      deser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d0321d
      ENTRY 3:
      class: java.lang.Object
      xsd_type: ['http://xml.domain.biz/2010/scoa:changestate']:stns:digest
      ser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d3dff6
      deser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1d3e04f


      Request (that works when sending through SOAPUI)



      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:scoa="http://xml.domain.biz/2010/scoa:changestate" xmlns:chan="http://xml.domain.biz/2010/scoa/changestate">
      <soapenv:Header/>
      <soapenv:Body>
      <scoa:digest>
      <Transicao idTransacao="1541772100700" numeroAgendamento="1035622" placaCarreta="KNX0002" compartimento="01" faseCarregamento="01"/>
      </scoa:digest>
      </soapenv:Body>
      </soapenv:Envelope>


      WSDL



      <?xml version="1.0" encoding="UTF-8"?>
      <wsdl:definitions xmlns:impl="http://xml.domain.biz/2010/scoa:changestate"
      xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
      xmlns:intf="http://xml.domain.biz/2010/scoa:changestate"
      targetNamespace="http://xml.domain.biz/2010/scoa:changestate">
      <wsdl:types>
      <schema xmlns="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://xml.domain.biz/2010/scoa:changestate">
      <element name="digest" type="xsd:anyType"></element>
      <element name="digestReturn" type="xsd:anyType"></element>
      </schema>
      </wsdl:types>
      <wsdl:message name="digestRequest">
      <wsdl:part element="impl:digest" name="part"></wsdl:part>
      </wsdl:message>
      <wsdl:message name="digestResponse">
      <wsdl:part element="impl:digestReturn" name="digestReturn"></wsdl:part>
      </wsdl:message>
      <wsdl:portType name="ChangeStateWS">
      <wsdl:operation name="digest">
      <wsdl:input message="impl:digestRequest" name="digestRequest"></wsdl:input>
      <wsdl:output message="impl:digestResponse" name="digestResponse"></wsdl:output>
      </wsdl:operation>
      </wsdl:portType>
      <wsdl:binding name="ChangeState.svcSoapBinding" type="impl:ChangeStateWS">
      <wsdlsoap:binding style="document"
      transport="http://schemas.xmlsoap.org/soap/http"></wsdlsoap:binding>
      <wsdl:operation name="digest">
      <wsdlsoap:operation soapAction=""></wsdlsoap:operation>
      <wsdl:input name="digestRequest">
      <wsdlsoap:body use="literal"></wsdlsoap:body>
      </wsdl:input>
      <wsdl:output name="digestResponse">
      <wsdlsoap:body use="literal"></wsdlsoap:body>
      </wsdl:output>
      </wsdl:operation>
      </wsdl:binding>
      <wsdl:service name="ChangeStateWSService">
      <wsdl:port name="ChangeState.svc" binding="impl:ChangeState.svcSoapBinding">
      <wsdlsoap:address
      location="http://domain.ltd/scoa/services/ChangeState.svc"></wsdlsoap:address>
      </wsdl:port>
      </wsdl:service>
      </wsdl:definitions>


      type-mappint



      <?xml version="1.0" encoding="UTF-8"?>
      <wsdd:type-mapping xmlns:wsdd="http://www.bea.com/servers/wls70"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
      <wsdd:type-mapping-entry class-name="java.lang.Object"
      type="xsd:anyType"
      serializer="weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec"
      deserializer="weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec">
      </wsdd:type-mapping-entry>
      <wsdd:type-mapping-entry xmlns:stns="http://xml.domain.biz/2010/scoa:changestate"
      class-name="java.lang.Object"
      type="stns:digestReturn"
      serializer="weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec"
      deserializer="weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec">
      </wsdd:type-mapping-entry>
      <wsdd:type-mapping-entry xmlns:stns="http://xml.domain.biz/2010/scoa:changestate"
      class-name="java.lang.Object"
      type="stns:digest"
      serializer="weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec"
      deserializer="weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec">
      </wsdd:type-mapping-entry>
      </wsdd:type-mapping>






      java web-services soap wsdl weblogic






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 14 '18 at 19:03







      Ruben Trancoso

















      asked Nov 14 '18 at 17:18









      Ruben TrancosoRuben Trancoso

      83952150




      83952150






















          1 Answer
          1






          active

          oldest

          votes


















          0














          The solution was simple (not to find it).



          In this case the problem was with weblogic-maven-plugin to build the WS Client



          <groupId>org.codehaus.mojo</groupId>
          <artifactId>weblogic-maven-plugin</artifactId>


          I just upgraded it to version 2.9.5 and changed the goal accordingly



          <goals>
          <goal>clientgen9</goal>
          </goals>


          and it get back to work with no changes on the original code.






          share|improve this answer
























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53305585%2fhow-to-programatically-construct-a-soap-request-based-on-wsdl-and-request-xml%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            The solution was simple (not to find it).



            In this case the problem was with weblogic-maven-plugin to build the WS Client



            <groupId>org.codehaus.mojo</groupId>
            <artifactId>weblogic-maven-plugin</artifactId>


            I just upgraded it to version 2.9.5 and changed the goal accordingly



            <goals>
            <goal>clientgen9</goal>
            </goals>


            and it get back to work with no changes on the original code.






            share|improve this answer





























              0














              The solution was simple (not to find it).



              In this case the problem was with weblogic-maven-plugin to build the WS Client



              <groupId>org.codehaus.mojo</groupId>
              <artifactId>weblogic-maven-plugin</artifactId>


              I just upgraded it to version 2.9.5 and changed the goal accordingly



              <goals>
              <goal>clientgen9</goal>
              </goals>


              and it get back to work with no changes on the original code.






              share|improve this answer



























                0












                0








                0







                The solution was simple (not to find it).



                In this case the problem was with weblogic-maven-plugin to build the WS Client



                <groupId>org.codehaus.mojo</groupId>
                <artifactId>weblogic-maven-plugin</artifactId>


                I just upgraded it to version 2.9.5 and changed the goal accordingly



                <goals>
                <goal>clientgen9</goal>
                </goals>


                and it get back to work with no changes on the original code.






                share|improve this answer















                The solution was simple (not to find it).



                In this case the problem was with weblogic-maven-plugin to build the WS Client



                <groupId>org.codehaus.mojo</groupId>
                <artifactId>weblogic-maven-plugin</artifactId>


                I just upgraded it to version 2.9.5 and changed the goal accordingly



                <goals>
                <goal>clientgen9</goal>
                </goals>


                and it get back to work with no changes on the original code.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 16 '18 at 16:30

























                answered Nov 16 '18 at 12:44









                Ruben TrancosoRuben Trancoso

                83952150




                83952150





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53305585%2fhow-to-programatically-construct-a-soap-request-based-on-wsdl-and-request-xml%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    這個網誌中的熱門文章

                    What does pagestruct do in Eviews?

                    Dutch intervention in Lombok and Karangasem

                    Channel Islands