Create web project
1. Open eclipse. Create new Dynamic web project. Click Next.
2. Provide project name, runtime (web server) etc. and click Next.
3. Click Next (Keeping default values), if it asks for Project facet.
4. Now, provide context root, content directory and java source directory (use default).
Click Next.
Click Next.
5. Click Finish.
Put WSDL in project
Make new folder under project folder for keeping WSDL file and put the WSDL file into it.
Set the Axis 2 Runtime in Eclipse preferences, if required
Axis 1 is implicitly avaliable in Eclipse. So if you need Axis 2 in the project, set this configuration.
1. Go to Preferences - Axis2 Preferences.
2. Click Browse and select the Axis-2 library folder.
3. Click OK.
It will automatically loads the library and gives you message.
Click Apply and then OK.
Set the Axis version in Eclipse preferences
(To tell the Axis version to generate the server side code)
1. Go to Preferences - Server and Runtime.
2. Set the Web service Runtime (Apache Axis for version 1; Apache Axis2for version 2)
3. Click Apply and then OK.
Generate skeleton code
1. Right click on WSDL and choose Web service - Generate Java bean skeleton.
2. The screen will come with lot of options :
a. Web service type: Top-down (WSDL to Java) or Bottom-up (Java to WSDL) Java bean web service.
(As we are creating WSDL to java classes for skeleton,choose Top-down option)
b. Service definition: Selected WSDL file path.
c. Slider with the steps to perform.
It has following steps : Develop service / Assemble service / Deploy service / Install service / Start service / Test service.
(Keep it "Develop service" for only skeleton generation)
Server : XYZserver
(The Axis versions will be displayed as set in Eclipse preferences)
First section : Server side Deployment selection - lets you choose the view of 2 other sections.
Web service runtime : Apache Axis version
This opens same settings as server configuration.
Service project : project name
(By default, It picks current project)
Click Next.
3. Second screen will allow you to define source folder for the skeleton code.
Click on Next, will generate the skeleton code.
What it will generate ?
- Java skeleton code
- Deploy / undeploy WSDD
- Final WSDL (inside WebContent / wsdl folder)
NOTE
If you generated stubs using the step : develop service in eclipse, put server-config.wsdd file
In case, when you are using step : develop service in the wizard, eclipse will not generate server-config.wsdd file.
So you need to manually put it in web project.
Put server-config.wsdd file in the project under WEB-INF folder. [Get any sample file from internet ]
Copy complete tag (which is under tag) from deploy.wsdd to the server-config.wsdd (under tag).
Implement the business logic
Find the implementation class XYZBindingImpl.java and write the implementation code.
Deploy this web project to the web server
Deploy directly to the configured server in Eclipse
- OR -
Make WAR file of the project and deploy in web server.
Check the WSDL file in browser
1. Goto the final WSDL which is generated inside WebContent \ wsdl folder.
2. Copy the SOAP address URL (Endpoint URL) given in thegenerated WSDL.
3. Paste the URL in browser and append ".wsdl" at end. Like,
http: // localhost:8080/Simulator_MyCo/services/dungeonsoapPort?wsdl
The WSDL will be displayed in browser, if it is deployed and run successfully.
Sample file : server-config.wsdd
<?xml version="1.0" encoding="UTF-8" ?>
<deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<globalConfiguration>
<parameter name="sendMultiRefs" value="true" />
<parameter name="disablePrettyXML" value="true" />
<parameter name="adminPassword" value="admin" />
<parameter name="attachments.Directory" value="E:\MyWorkspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\webapps\a\WEB-INF\attachments" />
<parameter name="dotNetSoapEncFix" value="true" />
<parameter name="enableNamespacePrefixOptimization" value="false" />
<parameter name="sendXMLDeclaration" value="true" />
<parameter name="sendXsiTypes" value="true" />
<parameter name="attachments.implementation" value="org.apache.axis.attachments.AttachmentsImpl" />
</globalConfiguration>
<handler name="LocalResponder" type="java:org.apache.axis.transport.local.LocalResponder" />
<handler name="URLMapper" type="java:org.apache.axis.handlers.http.URLMapper" />
<handler name="Authenticate" type="java:org.apache.axis.handlers.SimpleAuthenticationHandler" />
<service name="AdminService" provider="java:MSG">
<parameter name="allowedMethods" value="AdminService" />
<parameter name="enableRemoteAdmin" value="false" />
<parameter name="className" value="org.apache.axis.utils.Admin" />
<namespace>http://xml.apache.org/axis/wsdd/</namespace>;
</service>
<service name="Version" provider="java:RPC">
<parameter name="allowedMethods" value="getVersion" />
<parameter name="className" value="org.apache.axis.Version" />
</service>
<!-- Your service here -->
<transport name="http">
<requestFlow>
<handler type="URLMapper" />
<handler type="java:org.apache.axis.handlers.http.HTTPAuthHandler" />
</requestFlow>
<parameter name="qs:list" value="org.apache.axis.transport.http.QSListHandler" />
<parameter name="qs:wsdl" value="org.apache.axis.transport.http.QSWSDLHandler" />
<parameter name="qs.list" value="org.apache.axis.transport.http.QSListHandler" />
<parameter name="qs.method" value="org.apache.axis.transport.http.QSMethodHandler" />
<parameter name="qs:method" value="org.apache.axis.transport.http.QSMethodHandler" />
<parameter name="qs.wsdl" value="org.apache.axis.transport.http.QSWSDLHandler" />
</transport>
<transport name="local">
<responseFlow>
<handler type="LocalResponder" />
</responseFlow>
</transport>
</deployment>
No comments:
Post a Comment
Note: only a member of this blog may post a comment.