[英]Changing a SOAP WSDL endpoint in Java
I have a WSDL that defines a SOAP endpoint. 我有一个定义SOAP端点的WSDL。 Unfortunately the URL it defines is incorrect.
不幸的是,它定义的URL不正确。 This means when I try to call the service through Java, it is trying to hit an end point that does not exist.
这意味着当我尝试通过Java调用服务时,它试图达到一个不存在的终点。
Is there a way I can call a different endpoint through Java? 有没有一种方法可以通过Java调用其他端点? The WSDL contract cannot be changed unfortunately.
不幸的是,无法更改WSDL合同。 The Url I want to hit is https://mycorp.com/FBPMSMS.wsdl
我要点击的网址是https://mycorp.com/FBPMSMS.wsdl
Here is a snippet of my code, it was generated through CXF and wsdl2java 这是我的代码的一部分,它是通过CXF和wsdl2java生成的
@WebServiceClient(name = "FBPMSMSService",
wsdlLocation = "http://mycorp.com/FBPMSMS.wsdl",
targetNamespace = "http://mycorp.com")
public class FBPMSMSService extends Service {
public final static URL WSDL_LOCATION;
public final static QName SERVICE = new QName("http://mycorp.com", "FBPMSMSService");
public final static QName FBPMSMSPort = new QName("http://mycorp.com", "FBPMSMSPort");
static {
URL url = null;
try {
url = new URL("http://mycorp.com/FBPMSMS.wsdl");
} catch (MalformedURLException e) {
java.util.logging.Logger.getLogger(FBPMSMSService.class.getName())
.log(java.util.logging.Level.INFO,
"Can not initialize the default wsdl from {0}", "http://mycorp.com/FBPMSMS.wsdl");
}
WSDL_LOCATION = url;
}
Turned out to be very straight forward in the end. 最终证明是非常简单的。 I was able to use the below code to modify the endpoint address property on the WSDL
我能够使用下面的代码来修改WSDL上的端点地址属性
FBPMSMSService ss = new FBPMSMSService(wsdlURL, SERVICE_NAME);
FBPMSMSPortType port = ss.getFBPMSMSPort();
((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "https://mycorp.com/FBPMSMS");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.