Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using XML in Jar Files

Status
Not open for further replies.

Dagon

MIS
Jan 30, 2002
2,301
GB
I know very little about Java, but have had the misfortune to be tasked with writing an extract program to get some data from a server via its API. The problem I'm having is understanding the instructions required to connect to the API and there's not much assistance available.

The instructions I have been given are:

Code:
Web Service client using Java

This document outlines the necessary steps required to invoke a jets web service using Java.

1. Create a Client jar. Use clientgen task in your buildfile to create webservice client jar

   Copy the wsdl you are using to query DQS in build.xml file:
    
    <target name="generate-client">
      <clientgen wsdl="[URL unfurl="true"]http://xxx.xxx.xxx/DQS/DQService?WSDL"[/URL] packageName="dqsws" clientJar="DQSClient.jar">
          <classpath refid="project.class.path"/>
      </clientgen>
    </target>
      
3. Add this jar to your class path.This client jar will contain the implementation class to invoke the webservice.

4. The client class will use the implementation created as follows:

public class Client 
{
public static void main (String a[])
{
DQService_Impl implementation=null;
try
{
implementation = new DQService_Impl("[URL unfurl="true"]http://xxx.xxx.xxx/DQS/DQService?WSDL");[/URL]
} catch (IOException e) 
{
// TODO Auto-generated catch block
e.printStackTrace();
}
DQServicePort service = implementation.getDQServicePort();
String output = service.getDataDictionary(arg0, arg1, arg2, arg3, arg4, arg5);
}
}

Can someone interpret what this actually means in terms of practical steps ? I have a feeling it was written more for a Windows-based application, but I'm trying to do this on a UNIX (Sun) server.

What do I actually need to do to create my JAR file ? Do I just put the XML and the java code in the JAR file and it all just magically works, or is there a bit more to it ?
 
Before accusing me of that, look at my profile. Look in the Oracle forums in particular.

Yes, I am a Java newbie. I have done a little bit of JDBC work in the past, but I've not done much with Jar files and XML. I've basically had this piece of work dumped on me because there is no-one else who can do it. Unfortunately, no-one in the team knows Java and we need to write an interface program to get data from another system.

 
Two days of google searches have yielded the following.

a) Locate the WebLogic directory on the server and run the command to set up the environment.

b) create a build file that looks like this:

Code:
<project name="DQSClient" default="generate-client">
  <path id="project.class.path">
    <pathelement location="lib/"/>
    <pathelement path="${java.class.path}/"/>
    <pathelement path="${additional.path}"/>
  </path>
  <target name="generate-client">
    <clientgen wsdl="[URL unfurl="true"]http://xxx.xxx.xxx/DQS/DQService?WSDL"[/URL] packageName="dqsws" clientJar="DQSClient.jar">
         <classpath refid="project.class.path"/>
    </clientgen>
  </target>
</project>

c) Make sure the webserviceclient.jar (located somewhere under the WebLogic directory) is in your $CLASSPATH.

export CLASSPATH=$CLASSPATH:/xxx/xxx/xxx/webserviceclient.jar

d) Build using the WebLogic ant command:

ant

I probably should have posted in the WebLogic forum, but I didn't know I needed to use that when I started.
 
So you were asked to execute a WebService from Java? WebServicen can be executed with more platforms and programming languages.

Cheers,
Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top