01: package samples.encoding;
02:
03: import org.apache.axis.client.Call;
04: import org.apache.axis.client.Service;
05: import org.apache.axis.utils.Options;
06: import org.apache.axis.utils.XMLUtils;
07: import org.w3c.dom.Element;
08:
09: import javax.xml.namespace.QName;
10: import java.io.ByteArrayInputStream;
11: import java.net.URL;
12:
13: public class TestElem {
14: static String xml = "<x:hello xmlns:x=\"urn:foo\">a string</x:hello>";
15:
16: public static String doit(String[] args, String xml)
17: throws Exception {
18: ByteArrayInputStream bais = new ByteArrayInputStream(xml
19: .getBytes());
20:
21: String sURL = "http://" + args[0] + ":" + args[1]
22: + "/axis/services/ElementService";
23: QName sqn = new QName(sURL, "ElementService");
24: QName pqn = new QName(sURL, "ElementService");
25:
26: //Service service=new Service(new URL("file:ElementService.wsdl"),sqn);
27: Service service = new Service(new URL(sURL + "?wsdl"), sqn);
28: Call call = (Call) service.createCall(pqn, "echoElement");
29:
30: Options opts = new Options(args);
31: opts.setDefaultURL(call.getTargetEndpointAddress());
32: call.setTargetEndpointAddress(new URL(opts.getURL()));
33:
34: Element elem = XMLUtils.newDocument(bais).getDocumentElement();
35:
36: elem = (Element) call.invoke(new Object[] { "a string", elem });
37: return (XMLUtils.ElementToString(elem));
38: }
39:
40: public static void main(String[] args) throws Exception {
41: System.out.println("Sent: " + xml);
42: String res = doit(args, xml);
43: System.out.println("Returned: " + res);
44: }
45: }
|