gungor / spring-webclient-soap

38 stars 24 forks source link

Getting Error while trying to invoke SOAP service #4

Closed akhilev closed 3 years ago

akhilev commented 3 years ago

First of all thanks for this wonderful code. I am new to webflux and had used the similar code to setup a soap client for one of my project that is migrating from spring mvc.But when i try to invoke the service i am getting the below error. in Jaxb2SoapEncoder at the line
marshaller.marshal(value, message.getPayloadResult()); Error : (redacted)

org.springframework.core.codec.EncodingException: Could not marshal class com.package.InputType to XML; nested exception is javax.xml.bind.MarshalException

My generated class of InputType element is as follows (redacted)

      @XmlAccessorType(XmlAccessType.FIELD)
      @XmlType(name = "InputType", namespace = "http://www.domain.com/port", propOrder = {
        "requestl",
        "obj",

      })
      public class InputType {

      //getters and setters

      }

And also i have object factory class with qnames in the generated sources, ObjectFactory here allows me to programatically construct new instances of the Java representation for XML content.

      @XmlRegistry
      public class ObjectFactory {
       private final static QName _Std_QNAME = new QName("");
       //......
      //rest of the Qnames

      }

In Spring MVC i did the below ,not sure how this can be done in webflux

InputType inputType = objectFactory.createInputType();
//construct request using setters

and in the spring mvc soap client (i.e the one extends WebServiceGatewaySupport)

  JAXBElement<InputType> element = objectFactory.createInputType(inputType);

Also i need to add authentication to the request ( on spring mvc i added this as below) but i am not sure how to achieve the same using webflux. Could you please help me on the same or point me to the documentation i can refer to implement the same.

 @Bean
public Wss4jSecurityInterceptor securityInterceptor() {
    Wss4jSecurityInterceptor security = new Wss4jSecurityInterceptor();
    security.setSecurementActions(WSHandlerConstants.TIMESTAMP + " " + WSHandlerConstants.USERNAME_TOKEN);
    security.setSecurementPasswordType(WSConstants.PW_TEXT);
    security.setSecurementUsername(username);
    security.setSecurementPassword(password);
    return security;
gungor commented 3 years ago

Hi,

Your Input type does not have @XmlRootElement annotation. I think you send a subElement as a request. Is there any other generated class having this annotation?

gungor commented 3 years ago

Closing. Not an issue

pavithra10391 commented 1 year ago

Hi @gungor I am facing the same kinda issue. No generated classes having @XmlRootElement annotation. Could you please let us know how to marshal properly and how to add SSL certificate, keystore and Interceptors to WebClient