Announcement Announcement Module
Collapse
No announcement yet.
Spring Ws 2.1.0 with JIBX - No adapter for endpoint Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Ws 2.1.0 with JIBX - No adapter for endpoint

    Hi,

    I'm trying to deploy a sample webservice using JIBX for marshalling/unmarshalling. Am trying to consume the webservice from a junit test client that uses WebserviceTemplate for sending the message. I get the below error on the client side when trying to access the webservice -

    org.springframework.ws.soap.client.SoapFaultClient Exception: No adapter for endpoint [public com.emirates.emia.webservices.message.RewardAccoun tForDiningResponse com.emirates.emia.webservices.MealOrderEndPoint.ge tMenuForMealType(com.emirates.emia.webservices.mes sage.RewardAccountForDiningRequest)]: Is your endpoint annotated with @Endpoint, or does it implement a supported interface like MessageHandler or PayloadEndpoint?

    My web.xml entry contains the below entries -
    <servlet>
    <servlet-name>emia</servlet-name>
    <servlet-class>org.springframework.ws.transport.http.Messag eDispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>emia</servlet-name>
    <url-pattern>/emia/*</url-pattern>
    </servlet-mapping>

    <mime-mapping>
    <extension>wsdl</extension>
    <mime-type>text/xml</mime-type>
    </mime-mapping>

    <mime-mapping>
    <extension>xsd</extension>
    <mime-type>text/xml</mime-type>
    </mime-mapping>

    The endpoint is as given below -
    @Endpoint
    public class MealOrderEndPoint{

    private static final String NAMESPACE_URI = "http://localhost:8080/emia-webservices-1.0.0/emia";

    private MenuService menuService;

    public MealOrderEndPoint() {

    }

    @Autowired
    public MealOrderEndPoint(MenuService menuService) {
    this.menuService = menuService;
    }

    @PayloadRoot(namespace=NAMESPACE_URI, localPart="rewardAccountForDiningRequest")
    public @ResponsePayload RewardAccountForDiningResponse getMenuForMealType(@RequestPayload RewardAccountForDiningRequest req)
    {
    String mealTypeStr = req.getCreditCardNumber();
    System.out.println("mealType :" + mealTypeStr);

    RewardAccountForDiningResponse response = new RewardAccountForDiningResponse();
    response.setAmount(new BigDecimal(100));
    return response;
    }
    }

    Application context configuration is in a file named emia-servlet.xml. It contains the following -

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ws="http://www.springframework.org/schema/web-services"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/web-services http://www.springframework.org/schem...rvices-2.0.xsd
    http://www.springframework.org/schema/beans http://www.springframework.org/schem...ring-beans.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

    <context:component-scan base-package="com.emirates.emia.webservices"/>
    <ws:annotation-driven/>

    <ws:dynamic-wsdl id="emiaDefinition" portTypeName="EMIA"
    locationUri="http://localhost:8080/emia-webservices-1.0.0/emia">
    <ws:xsd location="/WEB-INF/schemas/message.xsd"/>
    </ws:dynamic-wsdl>
    </beans>

    The message.xsd is given below -

    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://localhost:8080/emia-webservices-1.0.0/emia" xmlns:r="http://localhost:8080/emia-webservices-1.0.0/emia"
    elementFormDefault="qualified">

    <xs:element name="rewardAccountForDiningRequest">
    <xs:complexType>
    <xs:attribute name="amount" use="required" type="xs:decimal" />
    <xs:attribute name="creditCardNumber" use="required" type="xs:string" />
    <xs:attribute name="merchantNumber" use="required" type="xs:string" />
    </xs:complexType>
    </xs:element>

    <xs:element name="rewardAccountForDiningResponse">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="menu" maxOccurs="unbounded">
    <xs:complexType>
    <xs:attribute name="confirmationNumber" type="xs:string" />
    <xs:attribute name="accountNumber" type="xs:string" />
    <xs:attribute name="amount" type="xs:integer" />
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>

    </xs:schema>


    The client code is -
    @ContextConfiguration("classpath:emia/ws/client/client-config.xml")
    @RunWith(SpringJUnit4ClassRunner.class)
    public class EmiaWebservicesTest {

    static final String NAMESPACE_URI = "http://www.emirates.com/emia/emia-mealorder";

    @Autowired WebServiceTemplate webServiceTemplate;


    @Test
    public void testWebServiceWithJIBX() throws Exception {
    try {

    RewardAccountForDiningRequest request = new RewardAccountForDiningRequest();
    request.setAmount(new BigDecimal("100.00"));
    request.setCreditCardNumber("1234123412341234");
    request.setMerchantNumber("1234567890");
    RewardAccountForDiningResponse confirmation = (RewardAccountForDiningResponse) webServiceTemplate.marshalSendAndReceive(request);

    } catch (Exception ex) {
    ex.printStackTrace();
    }

    }
    }

    client-config.xml -

    <bean class="org.springframework.ws.client.core.WebServi ceTemplate">
    <property name="marshaller" ref="marshaller" />
    <property name="unmarshaller" ref="unmarshaller" />
    <property name="defaultUri" value="http://localhost:8080/emia-webservices-1.0.0/emia" />
    </bean>

    <bean id="marshaller" class="org.springframework.oxm.jibx.JibxMarshaller ">
    <property name="targetClass" value="com.emirates.emia.webservices.message.Rewar dAccountForDiningResponse"/>
    </bean>
    <bean id="unmarshaller" class="org.springframework.oxm.jibx.JibxMarshaller ">
    <property name="targetClass"
    value="com.emirates.emia.webservices.message.Rewar dAccountForDiningRequest" />
    </bean>

    Can someone please tell me what I'm missing ?

    Many thanks!
Working...
X