RE: XML Document as parameter

<[email protected]> Mon, 29 Sep 2003 09:30:09 +0300
Newsgroups gmane.comp.java.enhydra.ksoap
Message-ID <[email protected]>
HI Jose,
    well, then your endpoint is a RPC-like webservice and you are trying to pass it
an input XML.
well, actually my app does not use RPC at all, but it just parses the incoming XML,
with this code (done using axis API) - so, i write the code for parsing XML - 
 
public Object parse(InputStream stream) throws Exception {

MessageFactory factory = MessageFactory.newInstance();

SOAPMessage message = factory.createMessage(new MimeHeaders(), stream); 

SOAPPart soapPart = message.getSOAPPart();

SOAPEnvelope envelope = soapPart.getEnvelope();

SOAPBody body = envelope.getBody();

SOAPElement agency = (SOAPElement)(body.getChildElements().next());

Agency _agency = new AgencyImpl();

Iterator iterator = agency.getChildElements();

while(iterator.hasNext()) {

SOAPElement elem = (SOAPElement)iterator.next();

String name = elem.getElementName().getLocalName();

String value = elem.getValue() != null ? elem.getValue() : "";

System.err.println("Got:" + name + "=" + value);

if(name.equals("name"))

_agency.setName(value);

else if(name.equals("tel"))

_agency.setTel(value);

else if(name.equals("email"))

_agency.setEmail(value);

else if(name.equals("contacted"))

_agency.setContacted(value);

else if(name.equals("contactperson"))

_agency.setContactPerson(value);

}

return _agency;

}

 
So, i m sorry i cannot help if you are trying to do a RPC like calls by passing an InputSource.
please check JAXRPC docs for supported datatypes, as far as i remember i did not see
a javax.xml.transform.Source in the supported types)
 
if u can quote me a reference to that i can investigate on how to do that
 
As far as i know, when u use saaj (ex JAXM) - when u want to send your own xml - it is reported to
extend some servlets (JAXMServlet or something else, depending on the implementation) in which there is some
default code (the onMessage() method) that parses the incoming XML.
 
hope this helps
 
    regards
    marco
 
 
 

-----Original Message-----
From: ext José Manuel Castro Preciado [mailto:[email protected]]
Sent: 24 September, 2003 17:51
To: Mistroni Marco (NET-IMN/Espoo)
Subject: RE: Ksoap: XML Document as parameter


Hi Marco,

I had test da example code you send me.. but, this is da message the server shows me:
[24/09/03 09:38:18:250 COT] 298e7ca8 WASStatelessE W SOAP0005W: Excepción de invocación: java.lang.NoSuchMethodException: syn._HelloWorld_Stub.recibeDocumento(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String) -- no signature match

I think that means that is not sending a 'xml document' but a list of parameters...  like i told you, da web service receive a Source (i had read in someplace that this can be use for receive xml documents)...
public String recibeDocumento(javax.xml.transform.Source doc)....

there's something i can do? or i have to make all the methods with n-parameters? i don't know..  i reviewed the page you told me, but, it has no examples of sending, only construct da xml document... :(
 
thanks a lot for ur info...  sorry my bad english :)
 
JM

[email protected] wrote:

Hi JM,
    below is a sample code for generating this kind of xml
 
<agency>
  <name>...</name>
  <tel>..</tel>
  <email>...</email>
  <contacted>...</contacted>
</agency>
 
   SoapObject method = new SoapObject(" http://www.tgmm.com/agenciesdemo", "agency");
   method.addProperty("name", name);
   method.addProperty("tel", phone);
   method.addProperty("email", email);
   method.addProperty("contacted", contact);
   method.addProperty("contactperson",person); 
   SoapSerializationEnvelope envelope =
    new SoapSerializationEnvelope(SoapSerializationEnvelope.VER10);
 
   envelope.bodyOut = method;
   System.err.println("connecting to new endpoint...");
    HttpTransport ht = new HttpTransport(" http://localhost:8080/struts/insert.do");//http://services.xmethods.net/soap <http://localhost:8080/struts/insert.do> ");
    try {
        System.err.println("midlet calling axis.......");
        ht.call(" http://localhost:8080/struts/insert.do", envelope);
    }  catch (Exception e) {
     System.err.println("edxceptjoen");
     e.printStackTrace();
    }

 
 
 
i hope  it'll help u in building ur XML..
for more complex samples, check this, from Michael Yuan (which is on this mailing list also :-)
 
http://www.javaworld.com/javaworld/jw-08-2002/jw-0823-wireless.html
 
 
regards
    marco
 




  _____  

Do You Yahoo!?
 <http://espanol.yahoo.com/mail_tagline/*http://espanol.news.yahoo.com>  Todo lo que quieres saber de Estados Unidos, América Latina y el resto del Mundo.
Visíta Yahoo!  <http://espanol.yahoo.com/mail_tagline/*http://espanol.news.yahoo.com> Noticias.