| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Important about wsdl elements which going to be use while creating client.<br> 1-spring-uri or endpoint of wsdl is known as <soap:address location=?> <br> 2-spring-soapAction or operation point is known as <soap:operation soapAction=?> <br> 3-you can find both value inside wsdl and use them in client code.
create spring boot project with dependency called-"spring-boot-starter-web-services"
add jaxws-maven-plugin into pom.xml and generated jaxb classes.
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>jaxws-maven-plugin</artifactId> <version>2.5</version> <executions> <execution> <id>wsimport-from-jdk</id> <goals> <goal>wsimport</goal> </goals> <configuration> <wsdlUrls> <wsdlUrl>http://www.dneonline.com/calculator.asmx?WSDL</wsdlUrl> </wsdlUrls> <packageName>com.amir.client</packageName> </configuration> </execution> </executions> </plugin>
create child class of WebServiceGatewaySupport to call the soap operation
public class SoapClientService extends WebServiceGatewaySupport {
@SuppressWarnings("unchecked")
public <T> T callSoapService(String location,String soapAction,Object request) {
T ret = null;
WebServiceTemplate webServiceTemplate = getWebServiceTemplate();
SoapActionCallback soapActionCallback = new SoapActionCallback(soapAction);
ret = (T) webServiceTemplate.marshalSendAndReceive(location, request, soapActionCallback);
return ret;
}
}
location --you can get from wsdl it is value of soap:address..
soapAction --you can get from wsdl it is valie of soap:operation..
create configuration class and add following 2 beans
1-Jaxb2Marshaller
2-SoapClientService (user class extends WebServiceGatewaySupport)
@Configuration
public class SoapConfiguration {
@Bean
public Jaxb2Marshaller marshaller() {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setContextPath("com.amir.client");
return marshaller;
}
@Bean
public SoapClientService soapClientService(Jaxb2Marshaller marshaller) {
SoapClientService client = new SoapClientService();
//default-uri means wsdl attribue called-<soap:address location=?)
//client.setDefaultUri("http://www.dneonline.com/calculator.asmx");//no need to tell soap:address(endpoint)
client.setMarshaller(marshaller);
client.setUnmarshaller(marshaller);
//for basic authentication you can use following..
//client.setMessageSender(httpComponentsMessageSender());
return client;
} }
| Back | FazBrowse Home | New Git URL |