I have a WSDL that defines a SOAP endpoint. Unfortunately the URL it defines is incorrect. This means when I try to call the service through Java, it is trying to hit an end point that does not exist.
Is there a way I can call a different endpoint through Java? The WSDL contract cannot be changed unfortunately. The Url I want to hit is https://mycorp.com/FBPMSMS.wsdl
Here is a snippet of my code, it was generated through CXF and 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
FBPMSMSService ss = new FBPMSMSService(wsdlURL, SERVICE_NAME);
FBPMSMSPortType port = ss.getFBPMSMSPort();
((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "https://mycorp.com/FBPMSMS");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.