Sunday, 18 October 2015

Consuming SOAP(Simple Object Access Protocol) Web Service using wsimport commnd

C:\Users\SynergisticIT\workspace\wsclient\src>
wsimport -keep -verbose   <wsdl-url>    -Xnocompile


parsing WSDL...


Generating code...

com\it\frog\soap\provider\FindFrogs.java
com\it\frog\soap\provider\FindFrogsResponse.java
com\it\frog\soap\provider\Frog.java
com\it\frog\soap\provider\FrogDataProvider.java
com\it\frog\soap\provider\FrogDataProviderService.java
com\it\frog\soap\provider\ObjectFactory.java
com\it\frog\soap\provider\UploadFrog.java
com\it\frog\soap\provider\UploadFrogResponse.java
com\it\frog\soap\provider\package-info.java


Note : to run above command we must set JDK path in the environment variable

Writing the client program...

main method...........


<service name="FrogDataProviderService">
<port name="FrogDataProviderPort" binding="tns:FrogDataProviderPortBinding">
<soap:address location="http://localhost:5555/spring-mvc-app/frogDataProvider"/>
</port>
</service>

<port name="FrogDataProviderPort" binding="tns:FrogDataProviderPortBinding">

//creating an instance of service "FrogDataProviderService" name

FrogDataProviderService dataProviderService=new FrogDataProviderService();
FrogDataProvider frogDataProvider=dataProviderService.getFrogDataProviderPort();
Frog frog=new Frog();
frog.setAge(12);
frog.setBreed("Panana");
frog.setColor("brown");
frog.setEmail("anshs@gmail.com");
frog.setName("Tommrmr");
frog.setFid("F49494");
String result=frogDataProvider.uploadFrog(frog);
System.out.println(result);


getFrogDataProviderPort()- port name prefix with get....

FrogDataProvider - This is port type define in WSDL


No comments:

Post a Comment