2
votes

I am new to Spring integration. I am trying to call soap webservice using Spring integration. I have webservice deployed at on my local server http://localhost:8080/DemoWebService/tickets.

Below are the configurations in Spring application context xml.

<int:gateway id="systemEntry" default-request-channel="requestChannel" default-reply-channel="responseChannel"
    service-interface="xpadro.spring.integration.ws.gateway.TicketService"/>
<int:channel id="requestChannel"/>
<int:channel id="responseChannel" />
<int-ws:outbound-gateway id="marshallingGateway"
    request-channel="requestChannel" reply-channel="responseChannel"
    uri="http://localhost:8080/DemoWebService/tickets" marshaller="marshaller"
    unmarshaller="marshaller"/>
<oxm:jaxb2-marshaller id="marshaller" contextPath="xpadro.spring.integration.ws.types" />

Below is the interface written as a gateway and a Junit test class.

public interface TicketService {

/**
 * Entry to the messaging system. All invocations to this method will be intercepted and sent to the SI "system entry" gateway
 * 
 * @param request
 */
@Gateway
public TicketResponse invoke(TicketRequest name );}

Code form Junit test

@Test
public void testInvocation() throws InterruptedException, ExecutionException {
    TicketRequest request = new TicketRequest();
    request.setFilmId("aFilm");
    request.setQuantity(new BigInteger("3"));

    TicketResponse response = service.invoke(request);

    assertNotNull(response);
    assertEquals("aFilm",response.getFilmId());
    assertEquals(new BigInteger("5"), response.getQuantity());
}

But when I run the test , I am getting below error. Please help. Thanks..

WARNING: Interceptor for {http://ws.mkyong.com/}tickets has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Message part {http://www.xpadro.spring.samples.com/tickets}ticketRequest was not recognized.  (Does it exist in service WSDL?)

This service works well from SOAP UI.

am I missing anything here? Please advice.

1

1 Answers

0
votes

Message part {http://www.xpadro.spring.samples.com/tickets}ticketRequest

You should really compare what you send to that service from code and what from SOAP UI.

Looks like you don't use the proper namespace in your JaxB generated domain classes.

Looks like the real namespace must be ws.mkyong.com.

Out of topic: I know who is xpadro :-), but you really should be sure that you are consistent with WSDL.