您好,我为使用SOAP服务创建了代码,
对于身份验证标头,我使用Wss4jSecurityInterceptor作为设置标头信息。
我收到下面这样的失败响应
Exception in thread "main" org.springframework.ws.soap.client.SoapFaultClientException: Required element {http://www.w3.org/2005/08/addressing}Action is missing我的配置代码如下
@Configuration
public class SoapClientConfig {
@Bean
public Jaxb2Marshaller marshaller() {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setContextPath("com.xyz.client");
marshaller.setCheckForXmlRootElement(false);
return marshaller;
}
@Bean
public MyClient myClient(Jaxb2Marshaller marshaller) throws Exception {
MyClient client = new MyClient();
client.setDefaultUri("https://localhost:8080/ws/service");
client.setMarshaller(marshaller);
client.setUnmarshaller(marshaller);
ClientInterceptor[] interceptors = new ClientInterceptor[] {securityInterceptor()};
client.setInterceptors(interceptors);
return client;
}
@Bean
public Wss4jSecurityInterceptor securityInterceptor() {
Wss4jSecurityInterceptor wss4jSecurityInterceptor = new Wss4jSecurityInterceptor();
wss4jSecurityInterceptor.setSecurementActions("UsernameToken");
wss4jSecurityInterceptor.setSecurementMustUnderstand(true);
wss4jSecurityInterceptor.setSecurementPasswordType("PasswordText");
wss4jSecurityInterceptor.setSecurementUsername("XXXXXXXXXXX");
wss4jSecurityInterceptor.setSecurementPassword("XXXXXXXX");
return wss4jSecurityInterceptor;
}
}有没有人能告诉我我遗漏了什么?
如果我在SOAPUI上尝试,它工作得很好。如果我在SOAPUI中设置WS-Addressing=false也会出现同样的错误,那么使用上面的代码设置WS-Addressing属性就会出现问题。我怎么能做到呢?
发布于 2017-03-28 19:45:22
您是否使用WebServiceTemplate发送请求?如果是,您可以执行以下操作:
ActionCallback callback = new ActionCallback(
new URI("action uri"));在这里你应该提供操作的实际uri位置,而不是"action uri“。然后,请执行以下操作
getWebServiceTemplate().marshalSendAndReceive(request, callback)发布于 2017-03-29 15:12:30
在使用动态值填充SOAP头之前很长一段时间,您需要使用回调object...WebServiceMessageCallback构造xml节点
http://docs.spring.io/spring-ws/site/reference/html/client.html#d5e1848
在我的场景中,我需要逐个节点地使用QName (Java)构建节点。
https://stackoverflow.com/questions/42943996
复制相似问题