Sending Complex Objects Using SOAP [message #170633] |
Mon, 05 June 2006 20:18 |
Eclipse User |
|
|
|
Originally posted by: yitzchok.rentmagic.ca
Hi.
I want to use Axis to return a simple class. When i try to generate the
Web Services I get 3 error messages. (Plus the error messege that TomCat 5
does not support Port Listening which is not true and I think I filed a
bug report on it - "IWAB0002I Apache Tomcat v5.5 does not support port
monitoring.")
First I get twice "Error in generating sample JSP" then an error message
window with no text message ("") with [OK/Details] and a lot of details.
Can someone just post code for me that will let me get a Complex Object
back from an Axis server using SOAP?
Using wtp-all-in-one-sdk-R-1.0.2-200604200208-win32.zip
-------------------------------------------------
Class code
-------------------------------------------------
public class MyClass
{
public MyClass() {};
protected int integer;
protected String str;
public String getStr() { return str;}
public int getInteger() { return integer;}
public void setStr(String str1) { str =str1;}
public void setInteger(int i) { integer = i;}
}
-------------------------------------------------
The servlet code (Dynamic Web Project)
-------------------------------------------------
public class serv {
public MyClass echo (int celsius)
{
MyClass t = new MyClass();
t.setInteger(celsius);
return t;
}
}
-------------------------------------------------
The client code:
-------------------------------------------------
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import org.ksoap2.*;
import org.ksoap2.serialization.*;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParserException;
public class test {
public static void main(String[] args) throws IOException,
XmlPullParserException {
SoapObject soap = new SoapObject("http://wtp", "echo");
soap.addProperty("celsius", 64);
SoapSerializationEnvelope envelope =
new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut = soap;
HttpTransportSE ht = new
HttpTransportSE("http://localhost:10477/serve/services/serv");
ht.call("http://schemas.xmlsoap.org/soap/envelope/", envelope);
SoapObject soapIn = (SoapObject)envelope.bodyIn;
System.out.print(soapIn.toString());
}
}
-------------------------------------------------
|
|
|
|
Powered by
FUDForum. Page generated in 0.02964 seconds