java - 如何使 JAX-WS 对 SOAP 使用 https(http 到 https):address in generated wsdl

标签 java web-services soap wsdl jax-ws

我正在使用 jax-ws 和 spring 创建 SOAP 网络服务。这是我的代码

@WebService
@Service
public class SoapService {
    SoapServiceDao soapServiceDao;
    @WebMethod(exclude = true)
    public void setSoapServiceDao(SoapServiceDao soapServiceDao) {
        this.soapServiceDao = soapServiceDao;
    }

    @WebMethod
    @SOAPBinding(parameterStyle=ParameterStyle.BARE)
    public Message method1(SoapResponse soapResponse) {
        return new Message();
    }
}

以及 application-context.xml

<wss:binding url="/soapservice">
    <wss:service>
        <ws:service bean="#soapserviceImpl" />
    </wss:service>

在生成的wsdl中

    <soap:address location="http://localhost:8080/soapservice"/>

但我想要https,因为我的服务器只接受https请求。

这种情况下可以把http改成https吗?

最佳答案

您可能需要以编程方式覆盖端点: 尝试将其更改为

MyServicePort myPort = new MyServiceInterface(new URL("https://acme.com/services/MyService.svc?wsdl")).getMyPort();
// set endpoint to use https
String endpointURL = "https://acme.com/services/MyService.svc";
BindingProvider bp = (BindingProvider) myPort;
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL);``
myPort.test();

关于java - 如何使 JAX-WS 对 SOAP 使用 https(http 到 https):address in generated wsdl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45049418/

相关文章:

java - Java 中的子字符串和 if 语句

java - 如何将邮件从 gmail 路由到 mailgun?

web-services - 报告 RESTful Web 服务内部服务错误 500 的最佳实践?

java - Netsuite 获取事务保存搜索 Java

iphone - 我在 Cocoa 的 SOAP XML 中使用什么数据类型作为整数?

java - 如何将倒排索引存储到二进制文件中?

java - 如何从存储在变量中的字符串调用 Java 函数

c# - 使用表单输入将文件上传到网络服务时遇到问题

Java-基于 Https 的 SOAP Web 服务

java - SOAP:如何在 Java 中调用 CountryInfoService WSDL 文件,例如使用 CapitalCity SOAP 操作