BAEL-3988: Calling a SOAP web service in Java (#9184)

* BAEL-3988: Calling a SOAP web service in Java

* BAEL-3988: modified generated class as per wsdl location change
This commit is contained in:
Sampada 2020-04-26 21:25:43 +05:30 committed by GitHub
parent 4a45d8c808
commit df179d642e
3 changed files with 6 additions and 47 deletions

View File

@ -256,10 +256,9 @@
</execution> </execution>
</executions> </executions>
<configuration> <configuration>
<wsdlDirectory>src/main/resources</wsdlDirectory> <wsdlUrls>
<wsdlFiles> <wsdlUrl>http://localhost:8888/ws/country?wsdl</wsdlUrl>
<wsdlFile>country.wsdl</wsdlFile> </wsdlUrls>
</wsdlFiles>
<keep>true</keep> <keep>true</keep>
<packageName>com.baeldung.soap.ws.client.generated</packageName> <packageName>com.baeldung.soap.ws.client.generated</packageName>
<sourceDestDir>src/main/java</sourceDestDir> <sourceDestDir>src/main/java</sourceDestDir>

View File

@ -12,11 +12,11 @@ import javax.xml.ws.WebServiceFeature;
/** /**
* This class was generated by the JAX-WS RI. * This class was generated by the JAX-WS RI.
* JAX-WS RI 2.3.2 * JAX-WS RI 2.2.9-b130926.1035
* Generated source version: 2.2 * Generated source version: 2.2
* *
*/ */
@WebServiceClient(name = "CountryServiceImplService", targetNamespace = "http://server.ws.soap.baeldung.com/", wsdlLocation = "file:src/main/resources/country.wsdl") @WebServiceClient(name = "CountryServiceImplService", targetNamespace = "http://server.ws.soap.baeldung.com/", wsdlLocation = "http://localhost:8888/ws/country?wsdl")
public class CountryServiceImplService extends Service { public class CountryServiceImplService extends Service {
private final static URL COUNTRYSERVICEIMPLSERVICE_WSDL_LOCATION; private final static URL COUNTRYSERVICEIMPLSERVICE_WSDL_LOCATION;
@ -27,7 +27,7 @@ public class CountryServiceImplService extends Service {
URL url = null; URL url = null;
WebServiceException e = null; WebServiceException e = null;
try { try {
url = new URL("file:src/main/resources/country.wsdl"); url = new URL("http://localhost:8888/ws/country?wsdl");
} catch (MalformedURLException ex) { } catch (MalformedURLException ex) {
e = new WebServiceException(ex); e = new WebServiceException(ex);
} }

View File

@ -1,40 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?><!-- Published by JAX-WS RI (http://jax-ws.java.net). RI's version is JAX-WS RI 2.2.9-b130926.1035 svn-revision#5f6196f2b90e9460065a4c2f4e30e065b245e51e. --><!-- Generated by JAX-WS RI (http://jax-ws.java.net). RI's version is JAX-WS RI 2.2.9-b130926.1035 svn-revision#5f6196f2b90e9460065a4c2f4e30e065b245e51e. -->
<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy"
xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://server.ws.soap.baeldung.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://server.ws.soap.baeldung.com/" name="CountryServiceImplService">
<types>
<xsd:schema>
<xsd:import namespace="http://server.ws.soap.baeldung.com/" schemaLocation="http://localhost:8888/ws/country?xsd=1"></xsd:import>
</xsd:schema>
</types>
<message name="findByName">
<part name="arg0" type="xsd:string"></part>
</message>
<message name="findByNameResponse">
<part name="return" type="tns:country"></part>
</message>
<portType name="CountryService">
<operation name="findByName">
<input wsam:Action="http://server.ws.soap.baeldung.com/CountryService/findByNameRequest" message="tns:findByName"></input>
<output wsam:Action="http://server.ws.soap.baeldung.com/CountryService/findByNameResponse" message="tns:findByNameResponse"></output>
</operation>
</portType>
<binding name="CountryServiceImplPortBinding" type="tns:CountryService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"></soap:binding>
<operation name="findByName">
<soap:operation soapAction=""></soap:operation>
<input>
<soap:body use="literal" namespace="http://server.ws.soap.baeldung.com/"></soap:body>
</input>
<output>
<soap:body use="literal" namespace="http://server.ws.soap.baeldung.com/"></soap:body>
</output>
</operation>
</binding>
<service name="CountryServiceImplService">
<port name="CountryServiceImplPort" binding="tns:CountryServiceImplPortBinding">
<soap:address location="http://localhost:8888/ws/country"></soap:address>
</port>
</service>
</definitions>