2014-10-06 38 views
1

我是新的春天web服务和教程的帮助我做了一个简单的web服务,但是当我试图在soapui上测试它没有响应任何输出。合同第一个春天的web服务

我附上所有需要的东西,请帮助我在哪里丢失。

XML模式

<?xml version="1.0" encoding="UTF-8"?> 
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.servesy-ws.com/services" xmlns:tns="http://www.servesy-ws.com/services" elementFormDefault="qualified"> 

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

    <xsd:element name="SignupResponse"> 
     <xsd:complexType> 
      <xsd:sequence> 
       <xsd:element name="response" type="xsd:string"/> 
      </xsd:sequence> 
     </xsd:complexType> 
    </xsd:element> 

</xsd:schema> 

行家依赖性

<properties> 
    <spring.version>3.1.1.RELEASE</spring.version> 
    <spring.ws.version>2.0.0.RELEASE</spring.ws.version> 
    <log4j.version>1.2.16</log4j.version> 
    <context.path>spring-webservices-sample</context.path> 
</properties> 
<build> 
<finalName>servesy-web</finalName> 
    <plugins> 
     <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> 
       <bindingDirectory>src/main/resources/bindings</bindingDirectory> 
       <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> 
<dependencies> 
    <dependency> 
     <groupId>log4j</groupId> 
     <artifactId>log4j</artifactId> 
     <version>${log4j.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-core</artifactId> 
     <version>${spring.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-context</artifactId> 
     <version>${spring.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-beans</artifactId> 
     <version>${spring.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-aop</artifactId> 
     <version>${spring.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-aspects</artifactId> 
     <version>${spring.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>commons-collections</groupId> 
     <artifactId>commons-collections</artifactId> 
     <version>3.2</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-oxm</artifactId> 
     <version>${spring.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.ws</groupId> 
     <artifactId>spring-ws-core</artifactId> 
     <version>${spring.ws.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.ws.commons.schema</groupId> 
     <artifactId>XmlSchema</artifactId> 
     <version>1.4.3</version> 
    </dependency> 
</dependencies> 

服务接口

package com.ws.servesy; 

    public interface SignupService { 

     public String response(String name); 

} 

服务实现

package com.ws.servesy; 

public class SignupServiceImpl implements SignupService { 

    public String response(String name) { 

     return name; 
    } 

} 

端点

package com.ws.endpoint; 

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 com.servesy_ws.services.SignupRequest; 
import com.servesy_ws.services.SignupResponse; 
import com.ws.servesy.SignupService; 


@Endpoint 
public class SignupServiceEndpoint { 

    private static final String TARGET_NAMESPACE = "http://www.servesy-ws.com/services"; 

    @Autowired 
    private SignupService signupservice; 

    @PayloadRoot(localPart = "SignupRequest", namespace = TARGET_NAMESPACE) 
    public @ResponsePayload SignupResponse getname(@RequestPayload SignupRequest request) { 
     SignupResponse signupresponse = new SignupResponse(); 
     String name = signupservice.response(request.getName()); 
     signupresponse.setResponse(name); 
     return signupresponse; 

    } 
} 

的web.xml

<?xml version="1.0" encoding="UTF-8"?> 
<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"> 

    <display-name>Archetype Created Web Application</display-name> 

<context-param> 
     <param-name>contextConfigLocation</param-name> 
     <param-value> 
      /WEB-INF/spring-ws-servlet.xml 
     </param-value> 
    </context-param> 

    <listener> 
     <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
    </listener> 

    <servlet> 
     <servlet-name>spring-ws</servlet-name> 
     <servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class> 
     <init-param> 
      <param-name>transformWsdlLocations</param-name> 
      <param-value>true</param-value> 
     </init-param> 
     <init-param> 
      <param-name>contextConfigLocation</param-name> 
      <param-value></param-value> 
     </init-param> 
     <load-on-startup>1</load-on-startup> 
    </servlet> 

    <servlet-mapping> 
     <servlet-name>spring-ws</servlet-name> 
     <url-pattern>*.wsdl</url-pattern> 
    </servlet-mapping> 

    <servlet-mapping> 
     <servlet-name>spring-ws</servlet-name> 
     <url-pattern>/endpoints/*</url-pattern> 
    </servlet-mapping> 

</web-app> 

Spring配置文件

<?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="com.ws.servesy" /> 
    <sws:annotation-driven /> 

    <!-- 
     Our test service bean 
    --> 
    <bean id="SignupService" 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/servesy-ws.xsd</value> 
        </list> 
       </property> 
      </bean> 
     </property> 
     <property name="portTypeName" value="SignupService"/> 
     <property name="serviceName" value="SignupServices" /> 
     <property name="locationUri" value="/endpoints"/> 
    </bean> 

</beans> 

和生成WSDL

<?xml version="1.0" encoding="UTF-8"?> 
-<wsdl:definitions targetNamespace="http://www.servesy-ws.com/services" xmlns:tns="http://www.servesy-ws.com/services" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:sch="http://www.servesy-ws.com/services" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"> 
    -<wsdl:types> 
     -<xsd:schema targetNamespace="http://www.servesy-ws.com/services" 
     elementFormDefault="qualified" attributeFormDefault="unqualified" 
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
      -<xsd:element name="SignupRequest"> 
      -<xsd:complexType> 
       -<xsd:sequence> 
        <xsd:element name="name" type="xsd:string"/> 
       </xsd:sequence> 
       </xsd:complexType> 
      </xsd:element> 
      -<xsd:element name="SignupResponse"> 
      -<xsd:complexType> 
       -<xsd:sequence> 
        <xsd:element name="response" type="xsd:string"/> 
       </xsd:sequence> 
       </xsd:complexType> 
      </xsd:element> 
     </xsd:schema> 
</wsdl:types> 
    -<wsdl:message name="SignupResponse"> 
     <wsdl:part name="SignupResponse" element="tns:SignupResponse"> </wsdl:part></wsdl:message> 
    -<wsdl:message name="SignupRequest"> 
     <wsdl:part name="SignupRequest" element="tns:SignupRequest"> 
</wsdl:part> 
</wsdl:message> 
     -<wsdl:portType name="SignupService"> 
     -<wsdl:operation name="Signup"> 
      <wsdl:input name="SignupRequest" message="tns:SignupRequest"> </wsdl:input> 
      <wsdl:output name="SignupResponse" message="tns:SignupResponse"> </wsdl:output> 
     </wsdl:operation> 
     </wsdl:portType> 
     -<wsdl:binding name="SignupServiceSoap11" type="tns:SignupService"> 
     <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/> 
     -<wsdl:operation name="Signup"> 
      <soap:operation soapAction=""/> 
      -<wsdl:input name="SignupRequest"> 
      <soap:body use="literal"/> 
     </wsdl:input> 
     -<wsdl:output name="SignupResponse"> 
      <soap:body use="literal"/> 
      </wsdl:output> 
      </wsdl:operation> 
     </wsdl:binding> 
     -<wsdl:service name="SignupServices"> 
      -<wsdl:port name="SignupServiceSoap11" binding="tns:SignupServiceSoap11"> 
       <soap:address location="http://localhost:9999/servesy-web/endpoints"/> 
      </wsdl:port> 
     </wsdl:service> 
     </wsdl:definitions> 
+0

请同时发布您的日志文件的输出。 – 2014-10-06 07:07:32

+0

@KurtDuBois我附上我的wsdl请看看它。 – maria 2014-10-06 07:18:36

回答