标签: spring-ws

Spring-WS 中的@PayloadRoot、@Action、@SoapAction

有人可以解释为什么我会在 spring-ws 中使用这些端点注释之一而不是另一个吗?特别是,哪一个被认为最具包容性?我可以同时使用这三个吗?我已阅读该文档,并且知道 @Action 使用 ws-addressing 而 @SoapAction 使用 SOAP Action 传输标头,但我不太确定哪个更适合使用。

谢谢。

java soap spring-ws ws-addressing

6
推荐指数
1
解决办法
3493
查看次数

无法让 Spring SOAP 客户端工作:内容类型“text/xml;” charset=utf-8' 不是预期的类型 'application/soap+xml; 字符集=utf-8'

你好,我正在尝试使用Spring-ws. 我对此错误所做的谷歌搜索表明我正在使用 Soap 1.1 并且需要指定 Soap 1.2。我已经尝试这样做了。我下面这样做正确吗?如果这不是问题,有人知道问题是什么吗?

这是堆栈跟踪的一部分

org.springframework.ws.client.WebServiceTransportException: Cannot process the message because the content type 'text/xml; charset=utf-8' was not the expected type 'application/soap+xml; charset=utf-8'. [415]
    at org.springframework.ws.client.core.WebServiceTemplate.handleError(WebServiceTemplate.java:663)
    at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:587)
    at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:537)
    at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:492)
    at org.springframework.ws.client.core.WebServiceTemplate.sendSourceAndReceiveToResult(WebServiceTemplate.java:436)
    at com.jda.fileserver.FujiAuthenticationTest.testLogin(FujiAuthenticationTest.java:53)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
Run Code Online (Sandbox Code Playgroud)

这是我的代码,感谢您的帮助:

public class AuthTest {
@Test
public void testLogin() throws Exception {
        StringBuffer loginXml = new StringBuffer();
        loginXml.append("<soapenv:Envelope xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:ns=\"http://abc.com/xyz/2010/08\">");
        loginXml.append("  <soapenv:Header>");
        loginXml.append("    <ns:loginOperationDetails>");
        loginXml.append("    </ns:loginOperationDetails>");
        loginXml.append("  </soapenv:Header>");
        loginXml.append("  <soapenv:Body>");
        loginXml.append("    <ns:LogIn>");
        loginXml.append(" …
Run Code Online (Sandbox Code Playgroud)

spring soap spring-ws soap-client

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

无法找到BeanDefinitionParser for Spring Web服务的元素

我是Spring Web服务的新手,我一直收到这个错误:

org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Cannot locate BeanDefinitionParser for element [annotation-driven]
Offending resource: ServletContext resource [/WEB-INF/spring-ws-servlet.xml]
Run Code Online (Sandbox Code Playgroud)

经过一番挖掘,看起来我很可能在我的架构和罐子之间存在版本不匹配但是我没有看到哪里(我正在为v3.1拍摄).

这是我库中的每个Spring jar:

M2_REPO\org\springframework\spring-aop\3.1.1.RELEASE\spring-aop-3.1.1.RELEASE.jar
M2_REPO\org\springframework\spring-asm\3.1.1.RELEASE\spring-asm-3.1.1.RELEASE.jar
M2_REPO\org\springframework\spring-beans\3.1.1.RELEASE\spring-beans-3.1.1.RELEASE.jar
M2_REPO\org\springframework\spring-context\3.1.1.RELEASE\spring-context-3.1.1.RELEASE.jar
M2_REPO\org\springframework\spring-context-support\3.1.1.RELEASE\spring-context-support-3.1.1.RELEASE.jar
M2_REPO\org\springframework\spring-core\3.1.1.RELEASE\spring-core-3.1.1.RELEASE.jar
M2_REPO\org\springframework\spring-expression\3.1.1.RELEASE\spring-expression-3.1.1.RELEASE.jar
M2_REPO\org\springframework\spring-jdbc\3.1.1.RELEASE\spring-jdbc-3.1.1.RELEASE.jar
M2_REPO\org\springframework\spring-jms\3.1.1.RELEASE\spring-jms-3.1.1.RELEASE.jar
M2_REPO\org\springframework\spring-oxm\3.1.1.RELEASE\spring-oxm-3.1.1.RELEASE.jar
M2_REPO\org\springframework\ws\spring-oxm\1.5.10\spring-oxm-1.5.10.jar
M2_REPO\org\springframework\ws\spring-oxm-tiger\1.5.10\spring-oxm-tiger-1.5.10.jar
M2_REPO\org\springframework\security\spring-security-acl\3.1.1.RELEASE\spring-security-acl-3.1.1.RELEASE.jar
M2_REPO\org\springframework\security\spring-security-config\3.1.1.RELEASE\spring-security-config-3.1.1.RELEASE.jar
M2_REPO\org\springframework\security\spring-security-core\3.1.1.RELEASE\spring-security-core-3.1.1.RELEASE.jar
M2_REPO\org\springframework\security\spring-security-remoting\3.1.1.RELEASE\spring-security-remoting-3.1.1.RELEASE.jar
M2_REPO\org\springframework\security\spring-security-taglibs\3.1.1.RELEASE\spring-security-taglibs-3.1.1.RELEASE.jar
M2_REPO\org\springframework\security\spring-security-web\3.1.1.RELEASE\spring-security-web-3.1.1.RELEASE.jar
M2_REPO\org\springframework\spring-test\3.1.1.RELEASE\spring-test-3.1.1.RELEASE.jar
M2_REPO\org\springframework\spring-tx\3.1.1.RELEASE\spring-tx-3.1.1.RELEASE.jar
M2_REPO\org\springframework\spring-web\3.1.1.RELEASE\spring-web-3.1.1.RELEASE.jar
M2_REPO\org\springframework\spring-webmvc\3.1.1.RELEASE\spring-webmvc-3.1.1.RELEASE.jar
M2_REPO\org\springframework\ws\spring-ws-core\2.1.2.RELEASE\spring-ws-core-2.1.2.RELEASE.jar
M2_REPO\org\springframework\ws\spring-ws-core-tiger\1.5.10\spring-ws-core-tiger-1.5.10.jar
M2_REPO\org\springframework\ws\spring-xml\1.5.10\spring-xml-1.5.10.jar
Run Code Online (Sandbox Code Playgroud)

弹簧-WS-servlet.xml中

<?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.1.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.1.xsd">

    <context:component-scan base-package="my.package"/>

    <sws:annotation-driven />

    <sws:dynamic-wsdl id="MyService"
        portTypeName="MyServiceInterface"
        locationUri="/myService/">
        <sws:xsd location="/WEB-INF/mySchema.xsd" />
    </sws:dynamic-wsdl>

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

web.xml中

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" …
Run Code Online (Sandbox Code Playgroud)

java spring xsd spring-ws

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

使用spring ws在soap请求中发送XmlData

我要求发XmlDataCDATA哪个返回一个附件的SOAP请求。

使用org.springframework.oxm.jaxb.Jaxb2Marshaller的编组与解组。

<![CDATA[<tag>Test</tag>]]> 这是我想在soap请求中发送的东西,远程服务希望它以相同的方式看到。

我已经创建了数据但是当我使用 webServiceTemplate.marshalSendAndReceive(payloadRequest, SoapActionCallback)

不知何故,有效载荷请求 xmltags 被编码并显示为

&lt;![CDATA[&lt;tag&gt;Test&lt;\tag&gt;

由于这种编码,远程服务无法处理请求并发送 org.springframework.ws.soap.client.SoapFaultClientException: Object reference not set to an instance of an object.

我该如何解决这个问题?有什么建议!

更新:spring mvc 的 defaultHtmlEscape 作为 web.xml 中的上下文参数是否负责这种行为?

java soap spring-ws

6
推荐指数
1
解决办法
6078
查看次数

如何使用spring-ws客户端使用不同的密钥库调用相同的Web服务

我有一些应用程序需要在同一个应用程序服务器中运行.每个应用程序都需要使用特定于该应用程序的证书通过同一Web服务进行身份验证.显然,我可以将所有证书放在同一个密钥库中,但是如何指定我必须使用哪个?对于我正在使用Spring WebServiceTemplate的调用,我想找到一些可以在spring xml配置文件中轻松配置的东西.

我试图遵循这个: 如何为Java服务器提供多个SSL证书

整个概念很清楚但我无法理解如何将它与Spring WebServiceTemplate链接以及如何在调用内部指定我必须使用的证书.

java ssl https spring spring-ws

6
推荐指数
2
解决办法
8882
查看次数

SOAPExceptionImpl:无效的内容类型:文本/html。这是错误消息而不是 SOAP 响应吗?

我需要有关调用 Web 服务的帮助。我org.springframework.ws.client用来调用WS,代码如下:

Response response = (Response) getWebServiceTemplate().marshalSendAndReceive(
                "http://ip:port/DefaultRequestListener?workflow=WsdlCPF&soapAction=Import",
                request,
                new SoapActionCallback("http://ip:port/DefaultRequestListener?workflow=WsdlCPF&soapAction=Import"));
Run Code Online (Sandbox Code Playgroud)

此外,我可以http://ip:port/DefaultRequestListener?workflow=WsdlCPF&soapAction=Import使用 SOAP UP调用 WS 并使用此链接(看起来很奇怪)接收响应。它工作正常。

从 IDE 运行代码后,我收到下一个堆栈跟踪:

Exception in thread "main" java.lang.IllegalStateException: Failed to execute CommandLineRunner
    at org.springframework.boot.SpringApplication.runCommandLineRunners(SpringApplication.java:677)
    at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:693)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:322)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:969)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:958)
    at com.mayacomp.feeder.Application.main(Application.java:33)
Caused by: org.springframework.ws.soap.SoapMessageCreationException: Could not create message from InputStream: Invalid Content-Type:text/html. Is this an error message instead of a SOAP response?; nested exception is com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Invalid Content-Type:text/html. Is this an error message instead of a …
Run Code Online (Sandbox Code Playgroud)

java soap spring-ws

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

将 Spring WS 故障状态代码从 500 更改为 400

我已经构建了 Spring WS 应用程序(基于 Spring WS 2.2.3),它公开了一个带有几个操作的小型 Web 服务。每个操作接收输入参数以搜索后端数据库并返回响应。一些参数是强制性的(例如街道名称),并且客户端要求如果对服务的请求缺少其中一些强制性参数(例如空街道名称),那么我的服务应该返回正确的 SOAP 错误,HTTP 状态为 400。

我的异常处理工作正常,如果请求消息中缺少某些必需的参数,我能够将正确的 SOAP 错误返回给客户端,并且 Spring WS 通过包装 SOAP 错误并将其发送回客户端来处理其余部分状态码为 500,如下所示:

HTTP/1.1 500 Internal Server Error
Server: Apache-Coyote/1.1
Accept: text/xml, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
SOAPAction: ""
Content-Type: text/xml;charset=utf-8
Content-Length: 503
Date: Thu, 10 Dec 2015 22:28:02 GMT

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Header/>
    <SOAP-ENV:Body>
        <SOAP-ENV:Fault>
            <faultcode>SOAP-ENV:Client</faultcode>
            <faultstring xml:lang="en">Street Name is required</faultstring>
        </SOAP-ENV:Fault>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Run Code Online (Sandbox Code Playgroud)

这很好,除了我真的希望 HTTP 状态代码是“400 错误请求”而不是“ 500 内部服务器错误”我不知道如何将状态代码从 500 更改为 400 并获得类似的响应下列的:

HTTP/1.1 400 …
Run Code Online (Sandbox Code Playgroud)

java spring soap web-services spring-ws

6
推荐指数
0
解决办法
2455
查看次数

在已经存在的WSDL中使用spring-ws

我是spring-ws的新手。我看到的所有教程都以xsd开始,最后生成了wsdl。当我们已经有wsdl时,该采用什么方法。

另外,我对已经讨论过的合同优先方法存有疑问(尽管我对答案并不确定)

spring-ws和合约至上的方法

我的任务是对现有的wsdl使用spring-ws。能否请您提供一种解决方法。

根据我的理解。在“合同优先”方法的过程中,我已经获得了合同,因此如何进行进一步操作未在任何教程中显示。

spring-ws

6
推荐指数
2
解决办法
5418
查看次数

为什么有时需要 SoapActionCallBack?

我正在使用 Spring-WS 开发一个 Web 服务客户端。这不是我的第一个使用 Spring-WS 的 Web 服务项目。但我是这个特定项目的新手。

我们使用 maven-jaxb2-plugin 生成 dao 对象。

我正在使用 Spring-WS WebServiceTemplate,带有标准编组器和解组器集。

在之前的项目中,我可以使用以下方式进行 Web 服务调用:

webserviceTemplate.marshallSendAndReceive(new ObjectFactory().createSomeRequest());
Run Code Online (Sandbox Code Playgroud)

在我当前的项目中,我需要提供一个 SoapActionCallback,与 SoapActionUrl 一起提供。

webserviceTemplate.marshallSendAndReceive(new ObjectFactory().createSomeRequest, new SoapActionCallback("http://some-action-url.com/action"));
Run Code Online (Sandbox Code Playgroud)

如果我不提供此 SoapActionUrl,我不会得到结果,并且在调试时,我会看到一个受抑制的异常:

Couldn't get a SAX parser while constructing a envelope
Run Code Online (Sandbox Code Playgroud)

我想删除那些 SoapActionUrls。使用maven-jaxb2-plugin正确生成的对象,应该自动引用正确的actionurl吗?

我用谷歌搜索过这个,但没有找到太多关于它的信息。我想知道为什么我可以在第一种情况下“保留 SoapActionCallback”,而在第二种情况下,我有义务提供此信息。我不知道服务器端使用的具体技术,因为网络服务是由外部合作伙伴开发的。

有人可以解释一下吗?

spring web-services spring-ws maven-jaxb2-plugin

6
推荐指数
0
解决办法
7684
查看次数

无法处理 mustUnderstand 标头:{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}安全。返回故障

我浏览了以下链接:SOAPFaultException "MustUnderstand headers (oasis-200401-wss-wssecurity-secext-1.0.xsd) are not understand",但仍在挣扎。

我正在使用Spring Boot v2.2.2..RELEASE and SOAP项目。

我正在将两个不同的 WSDL 文件加载到我的项目中。一个 URL 生成到http://localhost:8080/employee/employee-soap哪个工作正常。但这http://localhost:8080/student/student-soap给出了以下错误。

2020-02-17 15:31:00.241 WARN 20236 --- [nio-8080-exec-5] oswsoap.server.SoapMessageDispatcher:无法处理 mustUnderstand 标头:{ http://docs.oasis-open.org/wss /2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd }安全。返回故障

代码:

@EnableWs
@Configuration
public class AppConfig extends WsConfigurerAdapter {

    @SuppressWarnings({ "rawtypes", "unchecked" })
    @Bean
    public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
        MessageDispatcherServlet servlet = new MessageDispatcherServlet();
        servlet.setApplicationContext(applicationContext);
        servlet.setTransformWsdlLocations(true);
        return new ServletRegistrationBean(servlet, "/*");
    }

    @Bean
    public SaajSoapMessageFactory messageFactory() {
        SaajSoapMessageFactory messageFactory = new SaajSoapMessageFactory();
        messageFactory.setSoapVersion(SoapVersion.SOAP_11);
        messageFactory.afterPropertiesSet(); …
Run Code Online (Sandbox Code Playgroud)

java soap spring-ws spring-boot

6
推荐指数
1
解决办法
2351
查看次数