aspose file tools*
The moose likes Web Services and the fly likes  Need to create a web service in Java that reads data and results in XML.  Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark " Need to create a web service in Java that reads data and results in XML.  " Watch " Need to create a web service in Java that reads data and results in XML.  " New topic
Author

Need to create a web service in Java that reads data and results in XML.

Vidhi Sharma
Greenhorn

Joined: Mar 16, 2009
Posts: 4
Hi,


I need to create a web service using Java Implementation.
The Web service aim is to import the data from another application and map each field/column to the required XML output.


Here are my Version specs,
- JRE 1.6
- Eclipse3.4
- Type of webservice - Document literal.


I'm new to webservices. I've configured my eclipse environment. Please help me out how to proceed with it. Also need to publish this webservice on a server.

Thanks & Regards,
Vidhi
Vijay Kumar
Ranch Hand

Joined: Jul 24, 2003
Posts: 260
Hi Vidhi,

Welcome to Ranch.

I would like to know your deployment server.Its an application server or simple Servlet container like Tomcat. Which web services stack are you using Axis, JAX-WS or something else?

Regards,
Vijay Kumar
Vidhi Sharma
Greenhorn

Joined: Mar 16, 2009
Posts: 4
Hi Vijay,

Thanks for your reply.
Currently I'm using tomcat configured with my eclipse. The deployment server would also be the same.
My client is BMC remedy that will supply data fields to Java webservice, and that web service would result in XML.

I've never worked on Webservices earlier, just read documents/tutorials on internet. I'm not clear also which direction should I proceed with, whether JAXB or JAXWS or JAXP? According to my understanding, JAXP is used for Document-oriented webservices but their is limitation to transfer XML. Also please suggest me what should I go with.

Thanks & Regards,
Vidhi
Vijay Kumar
Ranch Hand

Joined: Jul 24, 2003
Posts: 260
Hi vidhi,

If you are using Tomcat (JSP/Servlet) container then you can use Axis2 for web services.See this url Axi2.

JAXB or JAXWS or JAXP?


JAX-WS - is latest web service stack its use JAXB internally to bind XML data mapping with JAVA and JAXP is use to process of XML document. JAXP vs JAXB

you can use document oriented web service using Axis2(JAX-WS). First you need to create schemas (.xsd) files which will be used for data binding and data validation for send and received from BMC remedy client. Then you need to create a WSDL file which will define your web service and the use axis2 runtime for creating web service.

--Vijay
Vidhi Sharma
Greenhorn

Joined: Mar 16, 2009
Posts: 4
Hello Vijay,

Thanks a lot. You showed me a path how to proceed further.
I've created .xsd files. While creating wsdl file using Axis2, I am encountered with the following error:

[ERROR] The service cannot be found for the endpoint reference (EPR) http://localhost:8080/ws4/services/AdminService
at org.apache.axis2.engine.DispatchPhase.checkPostConditions(DispatchPhase.java:65)
at org.apache.axis2.engine.Phase.invoke(Phase.java:333)
at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:264)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:163)
.........and a huge stacktrace



What should I handle this?

Regards,
Vidhi.
Vijay Kumar
Ranch Hand

Joined: Jul 24, 2003
Posts: 260
Hi,

I believe you are using JAVA2WSDL utility to create your web service using GUI of eclipse.

[ERROR] The service cannot be found for the endpoint reference (EPR


It should come after developing the web service. You can also post your WSDL and xsd file and also tell me how did you expose your webservice. It will help me to understand your problem clearly

Vijay
Vidhi Sharma
Greenhorn

Joined: Mar 16, 2009
Posts: 4
Vijay,

Yaa I am using JAVA2WSDL utility using GUI of eclipse, with preferences set to Axis2 environment.
I'm performing an R&D sort till now, just trying with 3 data fields only..


================================================================================
ws.xsd :

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/ws"
xmlns:tns="http://www.example.org/ws" elementFormDefault="qualified">

<complexType name="IncidentType">
<sequence>
<element name="FirstName" type="string"></element>
<element name="LastName" type="string"></element>
<element name="Value" type="int"></element>
</sequence>
</complexType>

<element name="Incident" type="tns:IncidentType" abstract="true"></element>
</schema>

================================================================================

ws4.wsdl -

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://DefaultNamespace" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://DefaultNamespace" xmlns:intf="http://DefaultNamespace" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)-->
<wsdl:types>
<schema elementFormDefault="qualified" targetNamespace="http://DefaultNamespace" xmlns="http://www.w3.org/2001/XMLSchema">
<element name="create">
<complexType/>
</element>
<element name="createResponse">
<complexType/>
</element>
</schema>
</wsdl:types>

<wsdl:message name="createRequest">

<wsdl:part element="impl:create" name="parameters"/>

</wsdl:message>

<wsdl:message name="createResponse">

<wsdl:part element="impl:createResponse" name="parameters"/>

</wsdl:message>

<wsdl:portType name="Ws4">

<wsdlperation name="create">

<wsdl:input message="impl:createRequest" name="createRequest"/>

<wsdlutput message="impl:createResponse" name="createResponse"/>

</wsdlperation>

</wsdl:portType>

<wsdl:binding name="Ws4SoapBinding" type="impl:Ws4">

<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

<wsdlperation name="create">

<wsdlsoapperation soapAction=""/>

<wsdl:input name="createRequest">

<wsdlsoap:body use="literal"/>

</wsdl:input>

<wsdlutput name="createResponse">

<wsdlsoap:body use="literal"/>

</wsdlutput>

</wsdlperation>

</wsdl:binding>

<wsdl:service name="Ws4Service">

<wsdl:port binding="impl:Ws4SoapBinding" name="Ws4">

<wsdlsoap:address location="http://localhost:8080/ws4/services/Ws4"/>

</wsdl:port>

</wsdl:service>

</wsdl:definitions>


================================================================================


I'm using SoapSonar application to validate 'n consume this wsdl.

Regards,
Vidhi
Balasubramanian Krishnaswamy
Greenhorn

Joined: Jun 26, 2007
Posts: 24
Friends,

I need a clarification from the link provided in the previous posts : http://www.eclipse.org/webtools/community/tutorials/TopDownAxis2WebService/td_tutorial.html

I am unable to proceed with the article as I could not find the "Axis Preference" sub preference under the "Web Service" preference.

I have attached the screen shot of the Windows --> Preference page for "Web Service".

I tried all the WTP plugin releases available in the Eclipse website but could not make "Axis Preference" to show up.

Could anyone please point me to the URL where I can find the relevant plugins for this.

Cheers,
Bala



[Thumbnail for Axis Preferences.jpg]

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need to create a web service in Java that reads data and results in XML.