2

I'm trying to write a fairly simple Spring-WS service which accepts a String and returns a String, I've defined the endpoint Class and as far as I can tell everything looks fine. But when I hit the service using SOAP-UI I get the following error message:

No adapter for endpoint [public java.lang.String uk.co.company.product.identification.service.IdentificationServiceEndpoint.getIdentificationData(java.lang.String)]: Is your endpoint annotated with @Endpoint, or does it implement a supported interface like MessageHandler or PayloadEndpoint?

I'm at my wits end because as far as I can tell everything is what it should be...

SPRING CONFIG

<?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: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">
    <context:component-scan base-package="uk.co.company.product.identification" />
    <sws:annotation-driven />
    <!-- Our test service bean -->
    <bean id="IdentificationRequest"
        class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition"
        lazy-init="true">
        <property name="schemaCollection">
            <bean
                class="org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection">
                <property name="inline" value="true" />
                <property name="xsds">
                    <list>
                        <value>/schemas/identificationOperations.xsd</value>
                    </list>
                </property>
            </bean>
        </property>
        <property name="portTypeName" value="IdentificationService" />
        <property name="serviceName" value="IdentificationServices" />
        <property name="locationUri" value="/endpoints/" />
    </bean>
</beans>

XSD

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns="http://www.company.co.uk/product/identification/service"
    targetNamespace="http://www.company.co.uk/product/identification/service"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">

    <xsd:element name="IdentificationRequest">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="address" type="xsd:string" />
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="IdentificationResponse">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="identificationData" type="xsd:string"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>

</xsd:schema>

ENDPOINT Class

package uk.co.company.product.identification.service;

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;

@Endpoint
public class IdentificationServiceEndpoint {

    private static final String TARGET_NAMESPACE = "http://www.company.co.uk/product/identification/service";

    @Autowired
    private IdentificationService identificationService;

    @PayloadRoot(localPart="IdentificationRequest", namespace=TARGET_NAMESPACE)
    @ResponsePayload public  String getIdentificationData(@RequestPayload String address){
        return identificationService.getIdentificationData(address);
    }

    public void setIdentificationService(IdentificationService identificationService){
        this.identificationService = identificationService;
    }
}

Generated WSDL This is the WSDL that is generated when I browse to:

http://localhost:8080/IdentificationService/IdentificationRequest.wsdl

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://www.company.co.uk/product/identification/service" xmlns:tns="http://www.company.co.uk/product/identification/service" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:sch="http://www.company.co.uk/product/identification/service" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
    <wsdl:types>
        <xsd:schema targetNamespace="http://www.company.co.uk/product/identification/service" elementFormDefault="unqualified" attributeFormDefault="unqualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.company.co.uk/product/identification/service">
            <xsd:element name="IdentificationRequest">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="address" type="xsd:string"/>
                    </xsd:sequence>
                </xsd:complexType>

            </xsd:element>

            <xsd:element name="IdentificationResponse">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="identificationData" type="xsd:string"/>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
        </xsd:schema>
    </wsdl:types>

    <wsdl:message name="IdentificationRequest">
        <wsdl:part name="IdentificationRequest" element="tns:IdentificationRequest"> </wsdl:part>
    </wsdl:message>

    <wsdl:message name="IdentificationResponse">
        <wsdl:part name="IdentificationResponse" element="tns:IdentificationResponse"> </wsdl:part>
    </wsdl:message>

    <wsdl:portType name="IdentificationService">
        <wsdl:operation name="Identification">
            <wsdl:input name="IdentificationRequest" message="tns:IdentificationRequest"> </wsdl:input>
            <wsdl:output name="IdentificationResponse" message="tns:IdentificationResponse"> </wsdl:output>
        </wsdl:operation>
    </wsdl:portType>

    <wsdl:binding name="IdentificationServiceSoap11" type="tns:IdentificationService">
        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
        <wsdl:operation name="Identification">
            <soap:operation soapAction=""/>
            <wsdl:input name="IdentificationRequest">
                <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output name="IdentificationResponse">
                <soap:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>

    <wsdl:service name="IdentificationServices">
        <wsdl:port name="IdentificationServiceSoap11" binding="tns:IdentificationServiceSoap11">
            <soap:address location="http://localhost:8080/IdentificationService/endpoints/"/>
        </wsdl:port>

    </wsdl:service>
</wsdl:definitions>

SOAP Messages: These are the SOAP Message I send from SOAP-UI and what I recieve. The endpoint is:

http://localhost:8080/IdentificationService/endpoints/

Request:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://www.company.co.uk/product/identification/service">
   <soapenv:Header/>
   <soapenv:Body>
      <ser:IdentificationRequest>
         <address>test</address>
      </ser:IdentificationRequest>
   </soapenv:Body>
</soapenv:Envelope>

Response:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <SOAP-ENV:Body>
      <SOAP-ENV:Fault>
         <faultcode>SOAP-ENV:Server</faultcode>
         <faultstring xml:lang="en">No adapter for endpoint [public java.lang.String uk.co.company.product.identification.service.IdentificationServiceEndpoint.getIdentificationData(java.lang.String)]: Is your endpoint annotated with @Endpoint, or does it implement a supported interface like MessageHandler or PayloadEndpoint?</faultstring>
      </SOAP-ENV:Fault>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

For completeness sake here is my pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.springframework.samples.service.service</groupId>
    <artifactId>IdentificationService</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

    <properties>

        <!-- Generic properties -->
        <java.version>1.7</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

        <!-- Web -->
        <jsp.version>2.2</jsp.version>
        <jstl.version>1.2</jstl.version>
        <servlet.version>2.5</servlet.version>


        <!-- Spring -->
        <spring-framework.version>3.2.3.RELEASE</spring-framework.version>
        <spring.ws.version>2.0.0.RELEASE</spring.ws.version>

        <!-- Hibernate / JPA -->
        <hibernate.version>4.2.1.Final</hibernate.version>

        <!-- Logging -->
        <logback.version>1.0.13</logback.version>
        <slf4j.version>1.7.5</slf4j.version>

        <!-- Test -->
        <junit.version>4.11</junit.version>

        <!-- Context Path -->
        <context.path>IdentificationService</context.path>

    </properties>

    <dependencies>

        <!-- Spring MVC -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring-framework.version}</version>
        </dependency>
        <!-- Spring WS -->
        <dependency>
            <groupId>org.springframework.ws</groupId>
            <artifactId>spring-ws-core</artifactId>
            <version>2.2.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>wsdl4j</groupId>
            <artifactId>wsdl4j</artifactId>
            <version>1.6.3</version>
        </dependency>
        <dependency>
            <groupId>org.apache.ws.xmlschema</groupId>
            <artifactId>xmlschema-core</artifactId>
            <version>2.0.1</version>
        </dependency>

        <!-- Apache Commons -->
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.10</version>
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.3.6</version>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.3.2</version>
        </dependency>

        <!-- Other Web dependencies -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>${jstl.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>${servlet.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>${jsp.version}</version>
            <scope>provided</scope>
        </dependency>

        <!-- Spring and Transactions -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${spring-framework.version}</version>
        </dependency>

        <!-- Logging with SLF4J & LogBack -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>${logback.version}</version>
            <scope>runtime</scope>
        </dependency>

        <!-- Hibernate -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>${hibernate.version}</version>
        </dependency>



        <!-- Test Artifacts -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${spring-framework.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
            <plugins>
                <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>


            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxb2-maven-plugin</artifactId>
                <version>1.4</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>xjc</goal>
                        </goals>
                        <phase>generate-sources</phase>
                    </execution>
                </executions>
                <configuration>
                    <clearOutputDir>false</clearOutputDir>
                    <outputDirectory>src/main/java</outputDirectory>
                    <schemaDirectory>src/main/webapp/schemas</schemaDirectory>  
                    <includeSchema>**/*.xsd</includeSchema>       
                    <enableIntrospection>false</enableIntrospection>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <warName>${context.path}</warName>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>
2
  • Your endpoint is wrong... You should accept and return XML objects not a string...
    – M. Deinum
    Apr 16, 2015 at 10:27
  • I think you are right will try that and if it's the case respond. Do you want to post an answer so I can mark it as correct? Apr 16, 2015 at 10:33

2 Answers 2

5

Your method signature is off, instead of a String it expects a IdentificationRequest and IdentificationResponse as return type.

@PayloadRoot(localPart="IdentificationRequest", namespace=TARGET_NAMESPACE)
@ResponsePayload 
public IdentificationResponse getIdentificationData(@RequestPayload IdentificationRequest address){
    String identification = identificationService.getIdentificationData(address.getAddress());
    ObjectFactory factory = new ObjectFactory();
    IdentificationResponse response = factory.createIdentificationResponse();
    response.setIdentificationData(identification);
    return response;
}

Your method should look like something above.

0
1

There are couple of reasons why you could be seeing this error. 1. If you are looking at Spring web services example , then your jdom version could be incorrect. This is what pom should look like

<dependency>
    <groupId>org.jdom</groupId>
    <artifactId>jdom</artifactId>
    <version>2.0.2</version>
</dependency>
  1. If your method return type is incorrect as pointed above

  2. If you are using complex type, then make sure your bean has been annotated with @XmlRootElement

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.