标签: spring-ws

强制 Spring Web 服务将 xsd 命名空间添加到响应中

我正在使用 Spring WS 版本 1.5.8。我的回复如下:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> 
   <SOAP-ENV:Header/> 
   <SOAP-ENV:Body> 
      ...
   </SOAP-ENV:Body> 
</SOAP-ENV:Envelope>
Run Code Online (Sandbox Code Playgroud)

但是,我的客户(与我集成)要求我添加更多名称空间声明才能使解析成功:

<?xml version="1.0" encoding="UTF-8"?> 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                  xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">          
    <soapenv:Body> 
         ... 
    </soapenv:Body> 
</soapenv:Envelope> 
Run Code Online (Sandbox Code Playgroud)

我该怎么做?

xml web-services spring-ws namespaces

4
推荐指数
1
解决办法
5971
查看次数

Spring-WS:SimpleWsdl11Definition,具有WSDL的多节点分类

Spring-WS 1.5:使用SimpleWsdl11Definition,在XML配置中公开WSDL很简单(来自Spring-WS doc):

<bean id="orders" class="org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition">
    <constructor-arg value="/WEB-INF/wsdl/Orders.wsdl"/>
</bean>
Run Code Online (Sandbox Code Playgroud)

产生一个公开WSDL的URL:

http://localhost:8080/spring-ws/orders.wsdl
Run Code Online (Sandbox Code Playgroud)

SimpleWsdl11Definition bean id +".wsdl"在部署时成为WSDL URL的叶子,它涵盖单节点分类.

我需要支持具有多节点分类法的WSDL的暴露.

例如:

http://localhost:8080/spring-ws/domain/subdomain/foo.wsdl
Run Code Online (Sandbox Code Playgroud)

这是如何在Spring-WS中完成的?Bean ID属性不允许使用"/"字符,因此我想知道影响WSDL URL的方式是什么.

注意:使用生成的WSDL不会打开选项(出于向后一致性的原因),例如使用DefaultWsdl11Definition.与SimpleWsdl11Definition一样,我想将WSDL的请求映射到静态WSDL.

谢谢.

java wsdl web-services spring-ws

4
推荐指数
1
解决办法
5671
查看次数

验证错误中的披风"Spring-WS"

在发出SOAP请求并且验证失败时,我得到的响应是:

<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">Validation error</faultstring>
         <detail>
            <spring-ws:ValidationError xmlns:spring-ws="http://springframework.org/spring-ws">xyz-pattern-valid: Value '.....' is not facet-valid with respect to pattern '[0-9x]+' for type 'ABC'.</spring-ws:ValidationError>
         </detail>
      </SOAP-ENV:Fault>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Run Code Online (Sandbox Code Playgroud)

有没有办法摆脱各地的spring-ws显然暴露了底层SOAP服务使用的是Spring和Java?

我已经看过扩展PayloadValidatingInterceptor,但是看不到明显的方法来摆脱spring-ws标签.

java spring spring-ws

4
推荐指数
1
解决办法
658
查看次数

JAXB2-maven仅构建目标

我是第一个Java-Spring项目.我需要与几个Web服务进行通信.我提供了一些WSDL,所以我使用Jax2B来自动生成类.

<plugin>
                <groupId>org.jvnet.jaxb2.maven2</groupId>
                <artifactId>maven-jaxb2-plugin</artifactId>
                <version>0.9.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <schemaLanguage>WSDL</schemaLanguage>
                    <generatePackage>hello.wsdl</generatePackage>
                    <forceRegenerate>true</forceRegenerate>
                    <schemas>
                        <schema>
                            <url>http://wsf.cdyne.com/WeatherWS/Weather.asmx?wsdl</url>
                        </schema>
                    </schemas>

                </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)

我的项目是一个网络项目.这里的问题是,我的类是在目标文件夹中生成的,而不是在我的项目中生成的.有人有想法如何解决这个问题?正确生成类,但不在正确的目录中生成.如您所见,我现在正在使用测试wsdl和模型名称.我遵循了这个教程:http://spring.io/guides/gs/consuming-web-service/

提前谢谢了

wsdl spring-ws jaxb

4
推荐指数
1
解决办法
880
查看次数

Spring-ws SoapHeader在endpoint方法中进行访问

我们正在使用spring-ws 2.2.0开发一个契约优先的WebService.我们正在尝试使用AuthToken位于SoapHeader中的自定义标记来管理身份验证.该AuthToken结构如下:

<authToken>
    <username>USERNAME</xa:username>
    <password>PASSWORD</xa:password>
</authToken>
Run Code Online (Sandbox Code Playgroud)

我们能够在SoapHeader中生成包含指定自定义身份验证标记的WSDL模式.问题是当客户端对我们的服务器执行调用时,我们无法在Ws Endpoint实现中解组AuthToken标记(位于SoapHeader中).

使用@RequestPayload绑定方法签名中的注释(handleMethodRequest如下例所示),我们可以访问未编组的有效内容(位于SoapBody中).我们尝试使用SoapHeader内容做同样的事情而没有成功.在下面的代码示例中,我们将向您展示我们想要获得的内容:

1
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "methodRequest")
@ResponsePayload
public MethodResponse handleMethodRequest(@RequestPayload MethodRequest request, @SoapHeader(value = "authToken") AuthToken authToken) { }

2
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "methodRequest")
@ResponsePayload
public MethodResponse handleMethodRequest(@RequestPayload MethodRequest request, AuthToken authToken) { }

3
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "methodRequest")
@ResponsePayload
public MethodResponse handleMethodRequest(@RequestPayload MethodRequest request, org.springframework.ws.soap.SoapHeader header) { }

4
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "methodRequest")
@ResponsePayload
public …
Run Code Online (Sandbox Code Playgroud)

spring web-services spring-ws soapheader

4
推荐指数
1
解决办法
2257
查看次数

如何在客户端记录SOAP消息?

美好的一天.我正在学习如何编写连接到外部SOAP RCP样式的服务.我正在使用jaxws-maven-plugin插件从WSDL文件生成Java类.我正在使用Spring来创建Web服务客户端bean:

@Configuration
public class StoreServiceConfig {

    @Bean
    public StoreWS storeWS() throws IOException {
        JaxWsPortProxyFactoryBean factoryBean = new JaxWsPortProxyFactoryBean();
        factoryBean.setServiceInterface(StoreWS.class);
        factoryBean.setWsdlDocumentUrl(new ClassPathResource("/wsdl/StoreWS.wsdl").getURL());
        factoryBean.setNamespaceUri("urn_store");
        factoryBean.setServiceName("StoreWSService");
        factoryBean.setEndpointAddress("https://10.34.45.82/storeservice/services/StoreWS");
        factoryBean.setUsername("testuser");
        factoryBean.setPassword("testpassword");
        factoryBean.afterPropertiesSet();
        return (StoreWS) factoryBean.getObject();
    }
}
Run Code Online (Sandbox Code Playgroud)

为了测试客户端,我使用JUnit编写了一个测试类.我用这种方式打电话给客户:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = StoreServiceTestConfig.class)
public class StoreServiceImplTest {
    @Autowired
    private StoreWS storeWS;
    ...
    @Test
    public void testExecuteQuery() throws Exception {
        ...
        StoreResponseType response = storeWS.executeQuery(storeRequest);
        ...
    }
}
Run Code Online (Sandbox Code Playgroud)

现在,我需要测试将完整的传出和传入SOAP消息记录到控制台中.请问怎么做?越简单越好.

我找到了使用以下系统参数的建议,但它们都不适用于我:

com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.dump=true
com.sun.xml.ws.transport.http.client.HttpTransportPipe.dump=true
com.sun.xml.ws.transport.local.LocalTransportPipe.dump=true
com.sun.xml.ws.transport.http.HttpAdapter.dump=true
Run Code Online (Sandbox Code Playgroud)

我正在使用Spring配置类(没有XML)和所有依赖项的最新版本.

我找到了这个答案,但我不知道如何在我的场景中使用它.

提前谢谢了!Vojtech

编辑: 我的logback.xml看起来像这样,但我仍然看不到控制台中的任何肥皂消息:

<?xml version="1.0" encoding="UTF-8"?> …
Run Code Online (Sandbox Code Playgroud)

java spring-ws jax-ws soap-client java-ws

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

Spring Boot - 生成需要 application/soap+xml 内容类型的 SOAP Web 服务

我遵循了教程Produce SOAP WS。我更改了DefaultWsdl11Definition下面的内容WebServiceConfig,通过添加以下内容来为服务生成soap12绑定:

wsdl11Definition.setCreateSoap12Binding(true); 
Run Code Online (Sandbox Code Playgroud)

在我生成的 wsdl 文件中,我可以看到生成了 Soap12 的移植。但是,当我发送带有自定义标头的消息:Content-Type=application/soap+xml 时,出现异常:

com.sun.xml.internal.messaging.saaj.soap.SOAPVersionMismatchException: Cannot create message: incorrect content-type for SOAP version. Got: application/soap+xml Expected: text/xml
    at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.init(MessageImpl.java:379)
    at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.<init>(MessageImpl.java:301)
    at com.sun.xml.internal.messaging.saaj.soap.ver1_1.Message1_1Impl.<init>(Message1_1Impl.java:65)
    at com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl.createMessage(SOAPMessageFactory1_1Impl.java:59)
    at org.springframework.ws.soap.saaj.SaajSoapMessageFactory.createWebServiceMessage(SaajSoapMessageFactory.java:188)
    at org.springframework.ws.soap.saaj.SaajSoapMessageFactory.createWebServiceMessage(SaajSoapMessageFactory.java:60)
    at org.springframework.ws.transport.AbstractWebServiceConnection.receive(AbstractWebServiceConnection.java:92)
    at org.springframework.ws.transport.support.WebServiceMessageReceiverObjectSupport.handleConnection(WebServiceMessageReceiverObjectSupport.java:87)
    at org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter.handle(WebServiceMessageReceiverHandlerAdapter.java:61)
    at org.springframework.ws.transport.http.MessageDispatcherServlet.doService(MessageDispatcherServlet.java:293)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:644)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85)
    at …
Run Code Online (Sandbox Code Playgroud)

soap web-services spring-ws soap1.2 spring-boot

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

尝试在JBoss EAP 6.3上部署spring ws + saaj webapp时出现ClassNotFoundException

我正在尝试在JBoss EAP 6.3上部署我们的Web应用程序(在Tomcat 7中可以正常工作),但是在部署时我收到了以下ClassNotFoundException

15:49:21,953 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/xxx-webapp]] (ServerService Thread Pool -- 61) JBWEB000287: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageFactory' defined in class path resource [spring/appCtx-xxx-remoting-ws.xml]: Cannot create inner bean 'com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl#6f47288' of type [com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl] while setting bean property 'messageFactory'; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl] for bean with name 'com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl#6f47288' defined in class path resource [spring/appCtx-xxx-remoting-ws.xml]; nested exception is java.lang.ClassNotFoundException: com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl from [Module "deployment.xxx-webapp.war:main" from Service Module …
Run Code Online (Sandbox Code Playgroud)

java jboss spring spring-ws saaj

4
推荐指数
1
解决办法
5101
查看次数

Spring WS WebServiceTemplate:访问响应的内容或自定义解组器

我正在向外部SOAP服务发送一条消息,该消息应该以一条Soap Message进行响应,其中包含一个图像。这是我编写的用于发送消息的代码:

@Bean
Jaxb2Marshaller jaxb2Marshaller() {
    Jaxb2Marshaller jaxb2Marshaller = new Jaxb2Marshaller();
    jaxb2Marshaller.setContextPath("myContextPath");

    return jaxb2Marshaller;
}

@Bean
public WebServiceTemplate webServiceTemplate() {
    WebServiceTemplate webServiceTemplate = new WebServiceTemplate();
    webServiceTemplate.setMessageSender(webServiceMessageSender());
    webServiceTemplate.setMarshaller(jaxb2Marshaller());
    webServiceTemplate.setUnmarshaller(jaxb2Marshaller());
    webServiceTemplate.setDefaultUri(defaultUri);
    return webServiceTemplate;
}

public ProcessDocumentResponse sendRequest(MyRequest myRequest) {
    MyResponse response = (MyResponse) webServiceTemplate.marshalSendAndReceive(
            myRequest,
            message -> ((SoapMessage) message).setSoapAction(theAction));
    return response;
}
Run Code Online (Sandbox Code Playgroud)

这是从日志中得到的响应:

Receiving response: HTTP/1.1 200 OK
HTTP/1.1 200 OK
Cache-Control: private
Content-Type: multipart/related; type="application/xop+xml";start="<http://tempuri.org/0>";boundary="uuid:_someUUID_";start-info="text/xml"
Server: Microsoft-IIS/10.0
MIME-Version: 1.0
X-AspNet-Version: ...
X-Powered-By: ...
Date: Wed, 11 Oct 2017 09:10:36 GMT
Content-Length: …
Run Code Online (Sandbox Code Playgroud)

spring-ws mtom multipart jaxb unmarshalling

4
推荐指数
1
解决办法
1214
查看次数

Spring WS 客户端 - 使用服务器和客户端证书进行身份验证

我需要能够对 SOAP 服务进行“客户端证书”身份验证。

\n\n

我正在使用 Spring WS。我有: a my.key、 amyCA.pem和 a myClient.crt

\n\n

这是我的相关 Java 代码(我知道它仍然很混乱,但我只是想让它先工作):

\n\n
public TheResponse doIt(TheRequest request) {\n  log.info("Sending request...");\n  try {\n    InputStream is = new FileInputStream(new File("src/main/resources/keystore.jks"));\n    KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());\n    keyStore.load(is, "keystore!passwd".toCharArray());\n    is.close();\n    KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());\n    keyManagerFactory.init(keyStore, keyStorePassword.toCharArray());\n\n    InputStream is1 = new FileInputStream(new File("src/main/resources/truststore.jks"));\n    KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());\n    trustStore.load(is1, "truststore!passwd".toCharArray());\n    is1.close();\n    TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());\n    trustManagerFactory.init(trustStore);\n\n    HttpsUrlConnectionMessageSender messageSender = new HttpsUrlConnectionMessageSender();\n    messageSender.setKeyManagers(keyManagerFactory.getKeyManagers());\n    messageSender.setTrustManagers(trustManagerFactory.getTrustManagers());\n    setMessageSender(messageSender);\n\n    return (TheResponse) getWebServiceTemplate().marshalSendAndReceive(request,\n …
Run Code Online (Sandbox Code Playgroud)

ssl soap web-services spring-ws keystore

4
推荐指数
1
解决办法
9243
查看次数