Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Apache SOAP question

Reply
Thread Tools

Apache SOAP question

 
 
sarah chang
Guest
Posts: n/a
 
      01-12-2004
I want to implement a variety of SOAP methods (with Apache SOAP) using
just one method of one Java class, with the SOAP method name passed as
a
parameter to the Java method and the SOAP parameters passed in as an
array of Strings.

For example, the method could look like this:

public static void executeSoapMethod (String soapMethodName, String[]
soapParams) {
////
}

The reason for this is that I am writing an application that will
allow users to define their own SOAP operations interactively in a
proprietary scripting language.

Is anyone aware of a way I can do this?

Thanks!
 
Reply With Quote
 
 
 
 
Patrick B. Haggood
Guest
Posts: n/a
 
      01-14-2004

This is still a work in progress for me; but the direction I'm going is
adapted from examples out of chaper 14 in 'Professional Java Web Services'
from Wrox Press. Maybe you can use it as a starting point on your own.
I'm depending on JDOM for assembling/disassembling my commands and params
into XML docs.

**************************************************

package codezilla.client.soap;


/**
* Write a description of class TrinitySOAPCall here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class TrinitySOAPCall
{
// instance variables - replace the example below with your own
private static String endpointURL =
"http://localhost:8080/axis/Trinity";
Call call;
Service service;
Element root = new Element("params");
Document doc = new Document(root);

/**
* Constructor for objects of class TrinitySOAPCall
* Include and assign all variables that aren't call specific
*/
public TrinitySOAPCall(String methodname)
{
service = new Service();
call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpointURL));
call.setOperationName(methodName);
call.setProperty(Call.NAMESPACE,"urn:Trinity"); // greetingSpace
call.addParameter("xml", XMLType.XSD_STRING, Call.PARAM_MODE_IN); //
vector? array?
}

// execute the call and get back an XML doc in response
public Document callMethod()
{
try {
String response = (String) call.invoke( xmldoc.toString() );
return StringToJDOM(response);
} catch(Exception e){
System.out.println(e);
}
}

// create new elements in XML tree of call params
public void addParam( String name, String val) {
Element newcommand = new Element("param");
newcommand.setAttribute("name", name);
newcommand.setText("val", val);
doc.getroot().addContent(newcommand);
}

// xml converter
private Document StringToJDOM( String str) {
SAXBuilder builder = new SAXBuilder();

// command line should offer URIs or file names
try {
StringReader srdr = new StringReader(str); // create string
input stream
Document responsedoc = builder.build(srdr); // build DOM from
that stream
// If there are no well-formedness errors,
// then no exception is thrown
}
// indicates a well-formedness error
catch (JDOMException e) {
System.out.println(args[0] + " is not well-formed.");
System.out.println(e.getMessage());
}
catch (IOException e) {
System.out.println("Could not check " + args[0]);
System.out.println(" because " + e.getMessage());
}
return responsedoc;
}
}

************************************************** ************************
sarah chang wrote:
> I want to implement a variety of SOAP methods (with Apache SOAP) using
> just one method of one Java class, with the SOAP method name passed as
> a
> parameter to the Java method and the SOAP parameters passed in as an
> array of Strings.
>
> For example, the method could look like this:
>
> public static void executeSoapMethod (String soapMethodName, String[]
> soapParams) {
> ////
> }
>
> The reason for this is that I am writing an application that will
> allow users to define their own SOAP operations interactively in a
> proprietary scripting language.
>
> Is anyone aware of a way I can do this?
>
> Thanks!


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems running Apache FOP: org.apache.fop.fo.FOTreeBuilder fatalError Pablo Java 0 03-28-2007 02:31 PM
org/apache/xpath/objects/XObject incompatible with org/apache/xpath/objects/XNodeSet duduch_1er@hotmail.com XML 4 08-10-2006 01:38 PM
Apache FileUpload - java.lang.NoClassDefFoundError: org/apache/commons/io/FileCleaner kebabkongen@hotmail.com Java 2 03-16-2006 09:20 AM
AXIS jars org.apache.axis.wsi.* and org.apache.axis.transport.jms.* unkwb@web.de Java 0 02-23-2005 04:02 PM
Problem of using apache soap to consume WSE 2.0 soap attachment Mullin Yu ASP .Net Web Services 0 10-08-2003 08:09 AM



Advertisments