0

I have exposed a webservice bu using CXFEndpoint. However, there is an error that I guess, MessageContentsList problem can not be converted . May be I made a mistake. Could you help me?

 public CxfEndpoint insurerService() {
        CxfEndpoint serviceEndpoint = new CxfEndpoint();
        serviceEndpoint.setServiceClass(XXXX.class);
        serviceEndpoint.setAddress("/XXXX");
        serviceEndpoint.setDataFormat(DataFormat.POJO);
        serviceEndpoint.setServiceName(new QName("http://tempuri.org/","XXXX"));
        serviceEndpoint.setPortName("XXXXX");
        serviceEndpoint.setBus(bus);

        return serviceEndpoint;
    }

  from(getUrl())
                .id("xxxxx-service")
                .unmarshal().json(JsonLibrary.Jackson, xxxx.class)
                .to("bean-validator")
                .dynamicRouter(method(xxx, "route").getExpression())
                .marshal().json(JsonLibrary.Jackson, true); 

Response will return ;

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <soap:Fault>
         <faultcode>soap:Server</faultcode>
         <faultstring>java.lang.String cannot be cast to java.util.List</faultstring>
      </soap:Fault>
   </soap:Body>
</soap:Envelope>
Hasan Birol
  • 136
  • 1
  • 11
  • If you are using POJO mode, then you expect Camel to convert the SOAP message body into the model class(es) defined in the web-service contract/service class. Thus your unmarshalling step where you expect a JSON input does not really make sense. – Ralf Apr 01 '20 at 14:51
  • As I get your answer, do I need to use soap dataformat? By the way, the contract of the service result is String.class – Hasan Birol Apr 01 '20 at 15:19
  • Why invoke the complexity of SOAP web-services if you your intention is to work with JSON strings as your payload? You'd be much better off with a JAX-RS endpoint. Anyway, the string that you have in the exchange message body apparently does not fit your JSON model class. You could insert a `log` statement to check what exactly your message string looks like. – Ralf Apr 01 '20 at 16:32
  • As i remember i have checked the response. It was fit to my mappee object. Well, i had a chance to change the DATAFORMAT to PAYLOAD,CXF. It works but no response would return. I have to , i guess, unmarshall the object to soap response. I dont know what the exact exception that apache camel gave. – Hasan Birol Apr 01 '20 at 17:33
  • The actual problem is ** "org.apache.cxf.headers.Header.list -> "" .** Cant convert String to List. I dont know what I am doing wrong. – Hasan Birol Apr 01 '20 at 20:00
  • SOAP headers sent by the SOAP client are forwarded to the CXF service. If you do not want that these headers are forwarded you have to remove them in the Camel header "org.apache.cxf.headers.Header.list .. It is written on the wiki https://cwiki.apache.org/confluence/display/CAMEL/CXF. However, in my case, SOAP > CXF > CXF Service > CXFRS > CXF like this way. Any people could explain that why I need to remove the parts.. Btw, it would work by using .removeHeader(org.apache.cxf.headers.Header.HEADER_LIST) – Hasan Birol Apr 01 '20 at 20:10
  • Could you share an example request of yours? – Ralf Apr 02 '20 at 06:18

0 Answers0