Saturday, January 30, 2010

Generating Web Service using Axis2Java

Define a Java class for the Web Service

package com.mycompany.myproduct.um.subscriber.ws.profile;

public class SubscriberProfileWS {
public String updateSubscriber (String username, String password, SubscriberProfile profile) {
System.out.println ("USername is : " + username + " password :" + password);
return "messageis:1244";
}

public String createSubscriber (String username, String password, SubscriberProfile profile) {
System.out.println ("USername is : " + username + " password :" + password);
return "messageis:1244";
}

public String deleteSubscriber (String username, String password, String msisdn) {
System.out.println ("USername is : " + username + " password :" + password + " Msisdn :" + msisdn);
return "messageis:1244";
}

}

Please Note: SubscriberProfile class is a container .All the variables that you want to access from generated code must have setter and getters.


Execute the following commans:
[serkans@serkanslnx bin] java org.apache.ws.java2wsdl.Java2WSDL -cp ../java/classes -cn com.mycompany.myproduct.um.subscriber.ws.profile.SubscriberProfileWS -of ../resources/SubscriberProfileWS.wsdl

[serkans@serkanslnx bin] java org.apache.axis2.wsdl.WSDL2Java -uri ../resources/SubscriberProfileWS.wsdl -p com.mycompany.myproduct.um.subscriber.ws.profile.SubscriberProfileWS.adb -d adb -s -ss -sd -ssi -o sourceOut

note: source files are generated under sourceOut directory


How To Invoke From SoapUI
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://profile.ws.subscriber.um.myproduct.mycompany.com/xsd">
<soap:Header/>
<soap:Body>
<xsd:createSubscriber>
<xsd:username>funny</xsd:username>
<xsd:password>funny</xsd:password>
<xsd:profile>
<xsd:birthdate>2009-06-17T11:49:52.986-07:00</xsd:birthdate>
<xsd:chargingType>0</xsd:chargingType>
<xsd:company>mycompany</xsd:company>
<xsd:department>coe</xsd:department>
<xsd:emailAddress>mutlu.sen@gmail.com</xsd:emailAddress>
<xsd:faxNumber>3901234567</xsd:faxNumber>
<xsd:forceChangePassword>true</xsd:forceChangePassword>
<xsd:gsmPhoneNumber>3901234567</xsd:gsmPhoneNumber>
<xsd:homePhoneNumber>3901234567</xsd:homePhoneNumber>
<xsd:languageCode>en</xsd:languageCode>
<xsd:msisdn>3901234567</xsd:msisdn>
<xsd:password>1234</xsd:password>
<xsd:passwordSecurityEnabled>true</xsd:passwordSecurityEnabled>
<xsd:personalName>mutlu</xsd:personalName>
<xsd:secretQuestionAnswer>sakaci</xsd:secretQuestionAnswer>
<xsd:streetAddress>street</xsd:streetAddress>
<xsd:subcriberPolicyName>voice</xsd:subcriberPolicyName>
<xsd:subscriptionCosPolicyName>voice</xsd:subscriptionCosPolicyName>
<xsd:subscriptionPolicyName>voice</xsd:subscriptionPolicyName>
<xsd:subscriptionStatus>0</xsd:subscriptionStatus>
<xsd:title>mr</xsd:title>
<xsd:umEmailAddress>3901234567@um.life.com</xsd:umEmailAddress>
<xsd:username>3901234567</xsd:username>
<xsd:webPage>http://sunels.com</xsd:webPage>
<xsd:workPhoneNumber>3901234567</xsd:workPhoneNumber>
</xsd:profile>
</xsd:createSubscriber>
</soap:Body>
</soap:Envelope>

No comments:

Post a Comment