如何在java中添加soap标头
作者:互联网
我有一个来自oracle的NO-.net webservice
要访问我需要添加soap标头.如何在java中添加soap标头?
Authenticator.setDefault(new ProxyAuthenticator("username", "password"));
System.getProperties().put("proxySet", "true");
System.setProperty("http.proxyHost", "IP");
System.setProperty("http.proxyPort", "port");
proxy = new RegPresMed_Service(new URL("webservice")).getRegPresMed();
((BindingProvider) proxy).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "realwebservice");
((BindingProvider) proxy).getRequestContext().put("com.sun.xml.ws.request.timeout", new Integer(60000));
((BindingProvider) proxy).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "webserviceUsername");
((BindingProvider) proxy).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "webservicePassword");
这有必要吗?
((BindingProvider) proxy).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "webserviceUsername");
((BindingProvider) proxy).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "webservicePassword");
我的肥皂标题是这样的:
<wsse:Security soapenv:mustUnderstand="1"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-6"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>username</wsse:Username>
<wsse:Password
Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">password</wsse:Password>
<wsse:Nonce
EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">randomnaumber==</wsse:Nonce>
<wsu:Created>dateCreated</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
解决方法:
我做的,
只需按照本教程.很有帮助
是来自javadb的副本(因为已关闭)
http://informatictips.blogspot.pt/2013/09/using-message-handler-to-alter-soap.html
要么
http://www.javadb.com/using-a-message-handler-to-alter-the-soap-header-in-a-web-service-client
标签:ws-security,java,jax-ws,web-services,soapheader 来源: https://codeday.me/bug/20191003/1851068.html