AW: Newbie Help with Comples Type
"Hepp A., DP ITS,SMR,TR" <[email protected]> Thu, 23 Oct 2003 19:59:41 +0200
| Newsgroups | gmane.comp.java.enhydra.ksoap |
|---|---|
| Message-ID | <A1BD40E92A77D411BC820001FA3264CA0275DE69@NWTAH022.DeutschePost.de> |
There are 2 possibilities, as i found out, if anyone knows others, i´ll be
listening,too.
1.
- Write a class that implements org.ksoap.Marshal
- overwrite readInstance() and/or writeInstance() and register()
- create a ClassMap instance.
- register your class with the ClassMap.
- call the service and the Result gets mapped autmatically to the
corresponding object.
the register Method is quite important, as it maps the concrete Object-Class
to your Marshaller.
-------------------------------------START OF
CODE--------------------------------------
class MyOwnMarshallerClass{
// ... as described overwrite writeInstance and readInstance ...
public void register(ClassMap cm) {
cm.addMapping
("myNameSpaceGoesHere", "MyObjectClassName",
new MyObjectClassName.getClass(), this);
}
}
Example with a SE-Transport (is similar to HttpTransport):
// Anywhere else...
setransport = new HttpTransportSE("http://www.my.endpoint.url", "");
// this is important, as your namespace must fit,
// otherwise, your mapping will not work
setransport.setNamespace("myNameSpaceGoesHere");
// Creating the ClassMap and registering
// When using 1999 XML-Schema-Namespace use
// constructor ClassMap(true)
ClassMap cm = new ClassMap();
Marshal mps = new MyOwnMarshallerClass();
mps.register(cm);
SoapObject rpc = new SoapObject(namespace, "myMethodNameGoesHere");
setransport.setClassMap(cm);
// We set debug in Transport to true so we can reach the complete
//responseMessage.
setransport.debug = true;
MyObjectClassName anInstanceOfThatClass = new MyObjectClassName();
/* In this case an instance of MyObjectClassName gets marshalled
to be sent to the service.
It expects a String as result (an XML-Schema:string)
You can also expect any other objects by registering them and
casting the result.
But you have to unmarshal (deserialize) the XML-Stuff to the
objects yourself in the readInstance method.
*/
rpc.addProperty("MyObjectClassName",anInstanceOfThatClass);
try {
String result = (String)setransport.call(rpc);
}
-------------------------------------END OF
CODE--------------------------------------
2.Yes, there was this second possibility;)
You can create a SoapObject and add some Parameters, that kSoap can
recognize.
Then you add the SoapObject as Parameter to the SoapObject you make the call
with.
Example?
OK.
This one is by Sebastien Petrucci, who is on the list also...
http://ksoap.enhydra.org/project/mailingLists/ksoap/msg00739.html
BTW: a good option is to look at old entries of the mailing list:
http://ksoap.enhydra.org/project/mailingLists/ksoap/maillist.html
GL & HF
Best Regards
Alex Hepp
> -----Ursprüngliche Nachricht-----
> Von: Brian Mason [mailto:[email protected]]
> Gesendet: Donnerstag, 23. Oktober 2003 19:12
> An: '[email protected]'
> Betreff: Ksoap: Newbie Help with Comples Type
>
>
> I am trying to send and recieve complex data types and I am
> having trouble
> finding examples
> Any help would be nice.
>
>
> Thanks,
> Brian D. Mason
> Software Eng.
> Chrome Systems Corporation
>
> e-mail: [email protected]
> phone: 503-963-6338
> mobile: 503-708-1907
> fax: 503-963-6311
> toll-free: 800-936-8906
>
> Chrome Inventory Everywhere(tm) - Edit and Export Your Vehicle Data in
> Minutes...
> Click Here for Demo:
> <http://www.chrome.com/maing2/demos/demolist4.asp>
>
> Notice: This e-mail transmission and/or the attachments
> accompanying it may
> contain confidential information belonging to the sender or
> Chrome Systems
> Corporation. The information is only for the use of the
> intended recipient.
> If you have received this transmission in error, please
> notify the sender
> immediately by reply e-mail, and then destroy all copies of the
> transmission.
>
>
>
> _______________________________________________
> Ksoap mailing list
> [email protected]
> http://www.enhydra.org/mailman/listinfo.cgi/ksoap
>