标签: spring-ws

如何在POM.xml中设置对Spring Web Services的依赖

我在很多Maven依赖项上得到了这个,尽管当前的痛苦来源是Spring.

我将设置一个Spring版本并包含它:

 <spring-version>3.0.0.RELEASE</spring-version>

 <!-- Spring framework -->
 <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>${spring-version}</version>
 </dependency>
Run Code Online (Sandbox Code Playgroud)

哪个按预期工作.

然而,我在设置我对spring-ws-core对web服务的依赖时遇到了问题.我能在任何回购中找到的最新版本是2.0.0-M1.

http://mvnrepository.com/artifact/org.springframework.ws/spring-ws-core

关于我需要包含在我的maven POM中以获得Spring 3 Web服务工作的任何线索:)

spring maven-2 web-services spring-ws

2
推荐指数
1
解决办法
1万
查看次数

合并DispatcherServlet和MessageDispatcherServlet

有没有一种方法可以合并org.springframework.ws.transport.http.MessageDispatcherServletorg.springframework.web.servlet.DispatcherServlet

它们都用于不同的目的,但我想将它们合并到一个servlet中.这样我就可以简单地进行URL匹配,/*并且每次调用都可以从一个servlet进行.

下面web.xml工作正常,但我想将spring-ws的URL匹配更改为/*

<url-pattern>/*</url-pattern>


<servlet>
    <servlet-name>jsp</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>jsp</servlet-name>
    <url-pattern>/page</url-pattern>
</servlet-mapping>

<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>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>spring-ws</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>
Run Code Online (Sandbox Code Playgroud)


有什么想法吗?

spring-ws

2
推荐指数
1
解决办法
4566
查看次数

设置Spring Web Service时未找到端点映射

我是设置弹簧网络应用程序的初学者.我到目前为止,但现在我发现自己陷入困境.

我收到以下错误:

WARNING: No endpoint mapping found for [SaajSoapMessage {http://mycompany.com/weather/schemas}GetCities]
Run Code Online (Sandbox Code Playgroud)

主要问题是我已经没有想法查找调试信息.我修复了我见过的很多错误,但现在我甚至在日志中找不到错误.所以我有点绝望了.

这是我的web.xml

<web-app>
    <display-name>Weather report webservice</display-name>

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

    <servlet-mapping>
        <servlet-name>spring-ws</servlet-name>
        <url-pattern>/weatherws</url-pattern>
    </servlet-mapping>
</web-app>
Run Code Online (Sandbox Code Playgroud)

这就是我的spring-ws-servlet.xml

<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="path.to.weather"/>

    <sws:annotation-driven/>

</beans>
Run Code Online (Sandbox Code Playgroud)

这就是我的端点的样子:

@Endpoint
public class WeatherEndpoint {

    private static final String NAMESPACE_URI = "http://mycompany.com/weather/schema";

    private WeatherReportManager manager;

    @Autowired
    public WeatherEndpoint(WeatherReportManager manager) throws JDOMException {
        this.manager = manager;
    }

    @PayloadRoot(namespace = NAMESPACE_URI, …
Run Code Online (Sandbox Code Playgroud)

spring web-services spring-ws endpoint

2
推荐指数
1
解决办法
2万
查看次数

Maven无法找到org.springframework.ws:spring-ws:1.5.8

当我们尝试使用org.springframework.wspring-ws作为maven项目中的依赖项时:

<dependency>
    <groupId>org.springframework.ws</groupId>
    <artifactId>spring-ws</artifactId>
    <version>1.5.8</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

它没有找到.看着回购的pom就在那里,罐子也是如此,但罐子里的名字就像是spring-ws-1.5.8-all.jar.

我的问题:首先,我如何将其用作maven pom中的依赖项?第二,为什么这个文件这样命名?

java spring spring-ws version maven

2
推荐指数
1
解决办法
3621
查看次数

从 Spring WS Interceptor 获取请求参数

我正在使用带有 Spring WS 的 Jaxb 2,并且我有一个拦截器,它被定向到一个特定的有效负载,它工作正常。

这里我的需求是从我的拦截器的handleRequest方法中读取请求参数。我知道这应该是相当直接的。但是无法找到读取请求参数的方法。目前我的 handleRequest 方法如下所示。

@Override
public boolean handleRequest(MessageContext messageContext, Object endpoint)
    throws Exception {

    boolean proceed = true;

    SaajSoapMessage saajSoapMessage = 
                    (SaajSoapMessage) messageContext.getRequest();

    SOAPMessage soapMessage = saajSoapMessage.getSaajMessage();

    Document doc = saajSoapMessage.getDocument();

    Element element = doc.getElementById("request");
}
Run Code Online (Sandbox Code Playgroud)

我的端点类的相关部分是

@PayloadRoot(namespace = NAMESPACE, localPart = "confirOrderRequest")
public @ResponsePayload ConfirmOrderResponse handleConfirmOrder(
    @RequestPayload ConfirmOrderRequest confirmOrderRequest) {

     ...........
}
Run Code Online (Sandbox Code Playgroud)

这里我的要求是获取ConfirmOrderRequest拦截器 handleRequest 方法中附带的 orderId ,有没有办法直接做到这一点,或者我需要为此做一些 XML 解析?

java web-services spring-ws jaxb

2
推荐指数
1
解决办法
3617
查看次数

如何使用 Spring WS Test 测试 SOAPAction 标头

我的应用程序正在使用 spring-ws 的 WebServiceTemplate 调用外部 Soap WS,我在测试中使用 MockWebServiceServer 进行模拟。

它可以很好地根据请求有效负载模拟响应。

但是现在我想测试调用了哪个 SOAP 操作。它应该在请求的“SOAPAction”HTTP 标头中定义。

我正在使用 Spring-WS 2.1.4。

有谁知道是否可以测试它以及如何测试?

这是我的测试课:

public class MyWebServiceTest {
    @Autowired
    private WebServiceTemplate webServiceTemplate;

    private MockWebServiceServer mockServer;                                               

    @Before
    public void createServer() throws Exception {
        mockServer = MockWebServiceServer.createServer(webServiceTemplate);
    }

    @Test
    public void callStambiaWithExistingFileShouldSuccess() throws IOException {

        Resource requestPayload = new ClassPathResource("request-payload.xml");
        Resource responseSoapEnvelope = new ClassPathResource("success-response-soap-envoloppe.xml");

        mockServer.expect(payload(requestPayload)).andRespond(withSoapEnvelope(responseSoapEnvelope));
        //init job
        //myService call the webservice via WebServiceTemplate
        myService.executeJob(job);

        mockServer.verify();
        //some asserts
    }

}
Run Code Online (Sandbox Code Playgroud)

所以我要测试的是调用的soap动作。所以我想在我的测试课上做这样的事情:

mockServer.expect(....withSoapAction("calledSoapAction")).andRespond(...
Run Code Online (Sandbox Code Playgroud)

soap spring-ws soap-client

2
推荐指数
1
解决办法
2050
查看次数

使用Spring WS而不是JAX-WS的功能

对于基于SOAP的Web服务,为什么要选择Spring WS而不是JAX-WS.我已经阅读了一些文章甚至Spring WS doc功能,但我仍然不清楚.如果我需要说服某人使用Spring WS我不能.

所以我想要任何Web服务开发人员都能理解的简单术语的区别.

提前致谢.

java spring-ws

2
推荐指数
1
解决办法
4363
查看次数

Spring Web Service客户端XwsSecurityInterceptor afterCompletion异常

我已经实现了一个Spring Web Service ServerClient,其配置如下。

我选择使用simplePasswordSecurity机制,并且两侧都已安装好以处理此问题。到目前为止,我可以将请求从客户端发送到服务器,服务器将处理该请求并将响应发送回去。

在我的终端日志中,我可以看到客户端收到了响应,但是我无意中得到了这个异常:

java.lang.AbstractMethodError: org.springframework.ws.soap.security.xwss.XwsSecurityInterceptor.afterCompletion(Lorg/springframework/ws/context/MessageContext;Ljava/lang/Exception;)V
at org.springframework.ws.client.core.WebServiceTemplate.triggerAfterCompletion(WebServiceTemplate.java:806)
at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:615)
at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:555)
Run Code Online (Sandbox Code Playgroud)

....

有什么想法为什么我会得到这个例外?


服务器

spring-config.xml

<bean id="FinancialService" 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/FinancialServiceOperations.xsd</value>
                </list>
            </property>
        </bean>
    </property>

    <property name="portTypeName" value="FinancialService" />
    <property name="serviceName" value="FinancialService" />
    <property name="locationUri" value="/endpoints" />
</bean>

<sws:interceptors>
    <bean id="authenticationInterceptor" class="org.springframework.ws.soap.security.xwss.XwsSecurityInterceptor">
        <property name="policyConfiguration" value="/WEB-INF/spring-security.xml" />
        <property name="callbackHandlers">
            <list>
                <bean id="passwordValidationHandler" class="org.springframework.ws.soap.security.xwss.callback.SimplePasswordValidationCallbackHandler">          
                    <property name="users">  
                        <props>  
                            <prop key="myUser">myPassword</prop>
                        </props>
                    </property> …
Run Code Online (Sandbox Code Playgroud)

java spring web-services spring-ws java-ee

2
推荐指数
1
解决办法
6727
查看次数

据我所知,Spring-WS Service说“没有用于端点的适配器”

我正在尝试编写一个相当简单的Spring-WS服务,该服务接受一个String并返回一个String,我定义了终结点类,据我所知一切看起来都很好。但是,当我使用SOAP-UI访问服务时,出现以下错误消息:

终结点没有适配器[公共java.lang.String uk.co.company.product.identification.service.IdentificationServiceEndpoint.getIdentificationData(java.lang.String)]:终结点是否带有@Endpoint注释,或者是否实现了受支持的接口像MessageHandler或PayloadEndpoint?

我尽全力以赴,因为据我所知,一切都应该是……

弹簧配置

<?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>
Run Code Online (Sandbox Code Playgroud)

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" /> …
Run Code Online (Sandbox Code Playgroud)

spring web-services spring-ws

2
推荐指数
1
解决办法
2330
查看次数

弹簧启动Web服务与执行器

我检查了几个其他类似的问题,但没有找到解决方案.

所以我有配置了Web服务的spring boot项目:

@Configuration
public class WebServiceConfig {

@Autowired
private Bus bus;

@Bean
public Endpoint endpoint() {
    EndpointImpl endpoint = new EndpointImpl(bus, new ServiceImpl());
    endpoint.publish("/ws");
    return endpoint;
}
}
Run Code Online (Sandbox Code Playgroud)

ServiceImpl,如:

@javax.jws.WebService(serviceName = "ServiceImpl", portName = "ServiceImplPort", targetNamespace = "http://serivce.com/", endpointInterface = "pac.service...")
public class ServiceImpl... 
Run Code Online (Sandbox Code Playgroud)

服务很好.

我的POM实现如下:

...
<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-ws</artifactId>
        <version>1.3.5.RELEASE</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-spring-boot-starter-jaxws</artifactId>
        <version>3.1.7</version>
    </dependency>
   ...
Run Code Online (Sandbox Code Playgroud)

MainClass:

 @Configuration
 @EnableAutoConfiguration
 @EnableScheduling
 @EnableWebMvc
 @ComponentScan("com.package")
 public class Application extends SpringBootServletInitializer {

public static void main(String[] args) throws Exception { …
Run Code Online (Sandbox Code Playgroud)

spring spring-ws spring-boot spring-boot-actuator

2
推荐指数
1
解决办法
2276
查看次数