Something like this (code not tested)
--------------------------------------------------------------------------------------
Client side
----------------
String returnString = "";
Call c=new Call();
c = registerSettings( c );
c.setMethodName ("fetchData");
c = registerSettings( c );
c.setMethodName ("fetchData");
//fetchData is name of server side method
// Set up parameters to pass
Vector parameters = new Vector();
// Set up parameters to pass
Vector parameters = new Vector();
String customerID = "2100"; // or get cusotmerID from elsewhere!
parameters.addElement (new Parameter("customerID", String.class, customerID, null));
c.setParams (parameters);
Response r=null;
try
{
parameters.addElement (new Parameter("customerID", String.class, customerID, null));
c.setParams (parameters);
Response r=null;
try
{
// where mstrHostString = http://soapServer:8080
// in other words ip & port you have soap on
r = c.invoke ( new URL( mstrHostString + "/soap/servlet/rpcrouter"), "" );
}
catch ( Exception e )
{
System.out.println ("exception service not available on " + mstrHostString);
return;
r = c.invoke ( new URL( mstrHostString + "/soap/servlet/rpcrouter"), "" );
}
catch ( Exception e )
{
System.out.println ("exception service not available on " + mstrHostString);
return;
}
// Check the response.
if (r.generatedFault ())
{
Fault f = r.getFault();
System.out.println (" Fault Code = " + f.getFaultCode());
System.out.println (" Fault String = " + f.getFaultString());
}
else
{
Parameter returnObject = r.getReturnValue();
// Check the response.
if (r.generatedFault ())
{
Fault f = r.getFault();
System.out.println (" Fault Code = " + f.getFaultCode());
System.out.println (" Fault String = " + f.getFaultString());
}
else
{
Parameter returnObject = r.getReturnValue();
// return vector of objects - e.g. strings
//Vector returnVector = (Vector)returnObject.getValue();
//returnString = (String) returnVector.get( 0 );
//Vector returnVector = (Vector)returnObject.getValue();
//returnString = (String) returnVector.get( 0 );
or
// return just one string
returnString = (String)returnObject.getValue();
}
}
public Call registerSettings( Call c )
{
// SET TARGET URI
c.setSOAPTransport(httpConn);
c.setTargetObjectURI ("urn:xml-APP"); // name of app in soap admin
// SET METHOD BEING CALLED ON SERVER
c.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
return c;
}
{
// SET TARGET URI
c.setSOAPTransport(httpConn);
c.setTargetObjectURI ("urn:xml-APP"); // name of app in soap admin
// SET METHOD BEING CALLED ON SERVER
c.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
return c;
}
---------------------------------------------------------------------
server side
--------------
You need to specify the method names you are calling in soap in soap admin for xml-APP.
XML code :
call:
java org.apache.soap.server.ServiceManagerClient http://<ipaddress>:<port>/soap/servlet/rpcrouter deploy C:\soapcode\Deploy.xml
code:
-------------------------------------------------------------------
<isd:service xmlns:isd= "http://xml.apache.org/xml-soap/deployment"
id="urn:xml-App">
<isd:provider type="java" scope="Application"
methods="fetchData">
<isd:java class="com.yourcompany.yourpackage.serversideclass"/>
</isd:provider>
<isd:faultListener>
org.apache.soap.server.DOMFaultListener
</isd:faultListener>
</isd:service>
--------------------------------------------------------------------------------------
code in serversideclass
public Vector fetchData( String customerID)
{
{
// access your dastabase bean with customerID
return returnVector;
}
or
public String fetchData( String customerID)
{
{
// access your dastabase bean with customerID
return returnString;
}
Hope this helps. Dont know if this is perfect, but this is the way I do it.
Regards
Jonathan
Parames <[EMAIL PROTECTED]> wrote:
Thanks for your response ,
Any i have query ,Im trying to send string as
XML(Element) to the service where service needs to
fetch string matching datas from database.
XML like Addressbook example..
Can anyone send me some code for
sending stringas element,Bcoz in service im passing
resultset to element.
Can anyone help me??
My GUI code
public void actionPerformed(ActionEvent event)
{
String but = event.getActionCommand();
if (but == "OK" )
{
// IdToLookUp is the value i want to take
IdToLookUp =jTextField1.getText();
// HERE the STRING TO PASS AS ELEMENT
DocumentBuilder xdb =
XMLParserUtils.getXMLDocBuilder();
Document doc = xdb.newDocument();
Element custID = doc.createElement("CustomerID");
custID.appendChild(doc.createTextNode(IdToLookUp));
//make a call to soap server with customer ID
try{
// GetCustInfo() is the SOAP CLIENT where i need to
pass this element...
gci = new GetCustInfo();
Element element =gci.callCustSVC(customerId);}
catch (Exception e) {
e.printStackTrace();
System.out.println("ERROR "+e);
}
}
-------------------------------------------------------
Thanks in advance
Expecting to hear from you
regards
parames
__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com
Yahoo! Plus - For a better Internet experience