Note that there are some explanatory texts on larger screens.

plurals
  1. PONo adapter for endpoint SWS
    primarykey
    data
    text
    <p>I'm trying to create a simple Hello World WebService using <a href="http://static.springsource.org/spring-ws/sites/2.0/reference/html/tutorial.html">this</a> tutorial.</p> <p>I'm running Java 1.7.0_04, Spring 2.1, everything is built with Maven and deployed with Tomcat6. However, when trying to send a SOAP request (soapUI), server returns me</p> <pre><code>No adapter for endpoint [public org.jdom.Element com.mycompany.hr.ws.HolidayEndpoint.handleHolidayRequest(org.jdom.Element) throws java.lang.Exception]: Is your endpoint annotated with @Endpoint, or does it implement a supported interface like MessageHandler or PayloadEndpoint? </code></pre> <p>I think there is a problem with annotations, however this is how my files look like:</p> <p><strong>web.xml</strong></p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"&gt; &lt;display-name&gt;Khozzy custom WebService&lt;/display-name&gt; &lt;servlet&gt; &lt;servlet-name&gt;spring-ws&lt;/servlet-name&gt; &lt;servlet-class&gt;org.springframework.ws.transport.http.MessageDispatcherServlet&lt;/servlet-class&gt; &lt;init-param&gt; &lt;param-name&gt;transformWsdlLocations&lt;/param-name&gt; &lt;param-value&gt;true&lt;/param-value&gt; &lt;/init-param&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;spring-ws&lt;/servlet-name&gt; &lt;url-pattern&gt;/*&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;/web-app&gt; </code></pre> <p><strong>spring-ws-servlet.xml</strong></p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:sws="http://www.springframework.org/schema/web-services" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services-2.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"&gt; &lt;context:component-scan base-package="com.mycompany.hr.ws" /&gt; &lt;context:component-scan base-package="com.mycompany.hr.service" /&gt; &lt;sws:annotation-driven /&gt; &lt;sws:dynamic-wsdl id="holiday" portTypeName="HumanResource" locationUri="/holidayService/" targetNamespace="http://mycompany.com/hr/definitions"&gt; &lt;sws:xsd location="/WEB-INF/hr.xsd"/&gt; &lt;/sws:dynamic-wsdl&gt; &lt;/beans&gt; </code></pre> <p><strong>HolidayEndpoint.java</strong></p> <pre><code>package com.mycompany.hr.ws; import com.mycompany.hr.service.HumanResourceService; import org.jdom.Document; import org.jdom.Element; import org.jdom.JDOMException; import org.jdom.Namespace; import org.jdom.xpath.XPath; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.ws.server.endpoint.annotation.Endpoint; import org.springframework.ws.server.endpoint.annotation.PayloadRoot; import org.springframework.ws.server.endpoint.annotation.RequestPayload; import org.springframework.ws.server.endpoint.annotation.ResponsePayload; import java.text.SimpleDateFormat; import java.util.Date; @Endpoint public class HolidayEndpoint { private static final String NAMESPACE_URI = "http://mycompany.com/hr/schemas"; private XPath startDateExpression; private XPath endDateExpression; private XPath nameExpression; private HumanResourceService humanResourceService; @Autowired public HolidayEndpoint(HumanResourceService humanResourceService) throws JDOMException { this.humanResourceService = humanResourceService; Namespace namespace = Namespace.getNamespace("hr",NAMESPACE_URI); startDateExpression = XPath.newInstance("//hr:StartDate"); startDateExpression.addNamespace(namespace); endDateExpression = XPath.newInstance("//hr:EndDate"); endDateExpression.addNamespace(namespace); nameExpression = XPath.newInstance("concat(//hr:FirstName, ' ',//hr:LastName)"); nameExpression.addNamespace(namespace); } @PayloadRoot(namespace = NAMESPACE_URI, localPart = "HolidayRequest") @ResponsePayload public Element handleHolidayRequest(@RequestPayload Element holidayRequest) throws Exception { Element toReturn = null; SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); Date startDate = dateFormat.parse(startDateExpression.valueOf(holidayRequest)); Date endDate = dateFormat.parse(endDateExpression.valueOf(holidayRequest)); String name = nameExpression.valueOf(holidayRequest); humanResourceService.bookHoliday(startDate,endDate,name); return toReturn; } } </code></pre> <p><strong>hr.xsd</strong></p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:hr="http://mycompany.com/hr/schemas" elementFormDefault="qualified" targetNamespace="http://mycompany.com/hr/schemas"&gt; &lt;xs:element name="HolidayRequest"&gt; &lt;xs:complexType&gt; &lt;xs:all&gt; &lt;xs:element name="Holiday" type="hr:HolidayType"/&gt; &lt;xs:element name="Employee" type="hr:EmployeeType"/&gt; &lt;/xs:all&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;xs:complexType name="HolidayType"&gt; &lt;xs:sequence&gt; &lt;xs:element name="StartDate" type="xs:date"/&gt; &lt;xs:element name="EndDate" type="xs:date"/&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;xs:complexType name="EmployeeType"&gt; &lt;xs:sequence&gt; &lt;xs:element name="Number" type="xs:integer"/&gt; &lt;xs:element name="FirstName" type="xs:string"/&gt; &lt;xs:element name="LastName" type="xs:string"/&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;/xs:schema&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload