I used wsimport to generate client code from a WSDL file, I have managed to test this generated code and it works but with one problem, the code references the WSDL file like this,
static {
URL url = null;
try {
URL baseUrl;
baseUrl = com.spx.global.spf_wmis_dev.etq2sapintegration_zqm246f_etq_validate_matnr_webservice.matnr_provider.ETQ2SAPIntegrationZQM246FETQVALIDATEMATNRWebServiceMATNRProvider.class.getResource(".");
url = new URL(baseUrl, "file:/C:/Users/xx/Desktop/spx/wsdls/validate_MATNR.wsdl");
} catch (MalformedURLException e) {
logger.warning("Failed to create URL for the wsdl Location: 'file:/C:/Users/xx/Desktop/spx/wsdls/validate_MATNR.wsdl', retrying as a local file");
logger.warning(e.getMessage());
}
ETQ2SAPINTEGRATIONZQM246FETQVALIDATEMATNRWEBSERVICEMATNRPROVIDER_WSDL_LOCATION = url;
}
And I have created a mock service for that WSDL file using soapUI running on http://localhost:8088/validate
and if I use this exact URL in the WSDL file like this, everything works just fine.
<wsdl:port name="ETQ2SAPIntegration_ZQM246F_ETQ_VALIDATE_MATNR_WebService_MATNR_provider_Port" binding="tns:ETQ2SAPIntegration_ZQM246F_ETQ_VALIDATE_MATNR_WebService_MATNR_provider_Binder">
<soap:address location="http://localhost:8088/validate"/>
</wsdl:port>
Now I want to be able to specify the web service location without referring to the WSDL file, I tried many things like overriding the port endPointAddress,
ETQ2SAPIntegrationZQM246FETQVALIDATEMATNRWebServiceMATNRProvider ser= new ETQ2SAPIntegrationZQM246FETQVALIDATEMATNRWebServiceMATNRProvider(); this class extends the Service class
javax.xml.namespace.QName qn= new QName("http://SPF-WMIS-DEV.GLOBAL.SPX.COM/ETQ2SAPIntegration.ZQM246F_ETQ_VALIDATE_MATNR.WebService:MATNR_providera", "ETQ2SAPIntegration.ZQM246F_ETQ_VALIDATE_MATNR.WebService.MATNR_provider");
ser.addPort(qn,HTTPBinding.HTTP_BINDING, "http://localhost:8088/test");
ZQM246FETQVALIDATEMATNRResponse response = new ZQM246FETQVALIDATEMATNRResponse();
MATNRProviderPortType provider = ser.getETQ2SAPIntegrationZQM246FETQVALIDATEMATNRWebServiceMATNRProviderPort();
But no matter what I try the code just keeps trying to read the endPointAddress from the WSDL file, maybe what I am trying to do isn't doable meaning that I cant just get rid of the WSDL file, I am not sure at this point, so any advise would be more than helpful.
P.S: Don't blame me for not following the Java Naming Convention, and I hate it as much as you do.