Wednesday, 9 December 2015

What is wsgen command?

The wsgen tool is used to parse an existing web service implementation class and generates required files (JAX-WS portable artifacts) for web service deployment. This wsgen tool is available in $JDK/bin folder.

     We can use wsgen command for following.........

  1. Generates JAX-WS portable artifacts (Java files) for web service deployment.
  2. Generates WSDL and xsd files, for testing or web service client development.



Top Down Approach to develop the soap web service


JAX-RPC versus JAX-WS

http://www.ibm.com/developerworks/library/ws-tip-jaxwsrpc/
https://sites.google.com/site/easytolearnbyyou/docs-for-u/web-service/jax-ws-vs-jax-rpc

Web services have been around a while now. First there was SOAP. But SOAP only described what the messages looked like. Then there was WSDL. But WSDL didn't tell you how to write web services in Java™. Then along came JAX-RPC 1.0. After a few months of use, the Java Community Process (JCP) folks who wrote that specification realized that it needed a few tweaks, so out came JAX-RPC 1.1. After a year or so of using that specification, the JCP folks wanted to build a better version: JAX-RPC 2.0. A primary goal was to align with industry direction, but the industry was not merely doing RPC web services, they were also doing message-oriented web services. So "RPC" was removed from the name and replaced with "WS" (which stands for web Services, of course). Thus the successor to JAX-RPC 1.1 is JAX-WS 2.0 - the Java API for XML-based web services.

What different files are created when we run wsimport command

What different files are created when we run wsimport command




Tuesday, 8 December 2015

WSDL and UDDI

http://codeasp.net/articles/asp-net/16/what-is-wsdl


http://codeasp.net/CodeASPNETPics/ArticleImages/what-is-wsdl/WSDLPosition2.PNG


Original WSDL is not published in SOAP METRO Web Service

http://www.gpsprogramys.co.in/com.gps.quiz/programService?wsdl
Note : When I was putting WSDL inside webapp folder wsdl/ then original WSDL was not published


Solution :
Please keep WSDL and XSD inside the WEB-INF folder shown as below....



http://www.gpsprogramys.co.in/com.gps.quiz/programService?wsdl

<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"xmlns:tns="http://www.service.gps.com/model" name="ProgramsService" targetNamespace="http://www.service.gps.com/model">
<wsdl:types>
<xsd:schema>
<xsd:import namespace="http://www.service.gps.com/model" schemaLocation="http://localhost:5050/com.gps.quiz/programService?xsd=1"/>
</xsd:schema>
</wsdl:types>
<!--
class AddProgramRequest{ addProgramRequest addProgramInput; }
-->
<wsdl:message name="AddProgramRequest">
<wsdl:part name="addProgramInput" element="tns:addProgramRequest"/>
</wsdl:message>
<wsdl:message name="AddProgramResponse">
<wsdl:part name="return" element="tns:addProgramResponse"/>
</wsdl:message>
<wsdl:message name="FindProgramsRequest">
<wsdl:part name="FindProgramsInput" element="tns:findProgramsRequest"/>
</wsdl:message>
<wsdl:message name="FindProgramsResponse">
<wsdl:part name="return" element="tns:findProgramsResponse"/>
</wsdl:message>
<wsdl:portType name="ProgramService">
<wsdl:operation name="addProgram">
<wsdl:input message="tns:AddProgramRequest"/>
<wsdl:output message="tns:AddProgramResponse"/>
</wsdl:operation>
<wsdl:operation name="findPrograms">
<wsdl:input message="tns:FindProgramsRequest"/>
<wsdl:output message="tns:FindProgramsResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ProgramServiceBinding" type="tns:ProgramService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="addProgram">
<wsdl:documentation>protocol and style used to invoke this method</wsdl:documentation>
<!-- it is showing intension of the web service -->
<soap:operation soapAction="http://www.service.gps.com/model/addProgram"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="findPrograms">
<wsdl:documentation>protocol and style used to invoke this method</wsdl:documentation>
<!-- it is showing intension of the web service -->
<soap:operation soapAction="http://www.service.gps.com/model/findPrograms"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ProgramSoapService">
<wsdl:port name="ProgramServicePort" binding="tns:ProgramServiceBinding">
<soap:address location="http://localhost:5050/com.gps.quiz/programService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>



Thursday, 22 October 2015

XSD (XML Schema Definition)

An XML Schema describes the structure of an XML document.

The purpose of an XML Schema is to define the legal building blocks of an XML document, just like a DTD.
An XML Schema:
  • defines elements that can appear in a document
  • defines attributes that can appear in a document
  • defines which elements are child elements
  • defines the order of child elements
  • defines the number of child elements
  • defines whether an element is empty or can include text
  • defines data types for elements and attributes
  • defines default and fixed values for elements and attributes

dog.xsd


<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.consultants.com/it"
xmlns:tns="http://www.consultants.com/it" elementFormDefault="qualified">
<element name="cdogs" type="tns:Dogs"/>
<element name="dogs" type="tns:Dogs"/>
<complexType name="Dogs">
<sequence>
<element name="dog" type="tns:Dog" maxOccurs="5" minOccurs="0"/>
</sequence>
</complexType>
<complexType name="Dog">
<sequence>
    <element name="name" type="string" maxOccurs="1" minOccurs="1"/>
     <element name="age" type="int" maxOccurs="1" minOccurs="1"/>
</sequence>
<attribute  name="color" type="string"  use="required"/>
 <attribute  name="mobile" type="string"  use="required"/>
</complexType>
</schema>









dog.xml

<?xml version="1.0" encoding="UTF-8"?>
<dogs xmlns="http://www.consultants.com/it" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.consultants.com/it dogs.xsd">
   <dog color="red" mobile="939393939">
    <name>name</name>
  <age>11</age>
   </dog>
   
   <dog color="pink"  mobile="93939393">
    <name>name</name>
  <age>22</age>
   </dog>
   
   
   <dog color="blue"  mobile="939393939">
    <name>name</name>
  <age>33</age>
   </dog>
   
   
   <dog color="pink" mobile="939393939">
    <name>name</name>
  <age>44</age>
   </dog>
   
   <dog color="yellow" mobile="939393939">
    <name>name</name>
  <age>55</age>
   </dog>
  
</dogs>