【问题标题】:JAXWS CLIENT ALWAYS SEND HTTP NOT HTTPSJAXWS 客户端总是发送 HTTP 而不是 HTTPS
【发布时间】:2020-02-13 12:52:18
【问题描述】:
您好,我在我的 java 项目中使用 jaxws 生成 wsdl。我使用 java 11 和 jaxws-maven-plugin 导入 mywsdl
Myproblem 在我的 wsdl 中有一个 http://myservice 块。我想使用 https://myservice 作为 url。
我生成并导入 wsdl。这总是尝试访问 http 地址而不是 https。如何强制我的 web 客户端使用 http 地址。
/**
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.3.2
* Generated source version: 2.2
*
*/
@WebServiceClient(name =
MyResponse response=reply.getMyService().MyRequest(request);
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.6</version>
【问题讨论】:
标签:
soap
jax-ws
jaxws-maven-plugin
【解决方案1】:
BindingProvider 就是解决方案。
QName qname2 = new QName("http://myschema", "MYserviceImpl");
Service service = MYserviceImpl.create(new URL("https://mysiteRequest"), qname2);
MYservice reply= service.getPort(MYservice.class);
BindingProvider bindingProvider = (BindingProvider)reply;
bindingProvider.getRequestContext().put(
BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
"https://mysite");
MyResponse response= reply.myRequest(request2);
【解决方案2】:
您是否尝试过 web.xml 中良好的旧安全约束?
<security-constraint>
<display-name>SecurityConstraint</display-name>
<web-resource-collection>
<web-resource-name>Secure Area</web-resource-name>
<url-pattern>/your-webservice-url</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>