1 16 17 package test.MSGDispatch; 18 19 import org.apache.axis.AxisFault; 20 import org.apache.axis.message.SOAPBodyElement; 21 import org.apache.axis.message.SOAPEnvelope; 22 import org.apache.axis.message.SOAPHeaderElement; 23 import org.apache.axis.utils.XMLUtils; 24 import org.w3c.dom.Document ; 25 import org.w3c.dom.Element ; 26 27 import java.io.ByteArrayInputStream ; 28 import java.io.InputStream ; 29 30 38 public class TestService { 39 public void testBody(int t) {} 45 public void testElement(int t) {} 46 public void testEnvelope(int t) {} 47 48 public SOAPBodyElement [] testBody(SOAPBodyElement [] bodies) 49 throws Exception { 50 51 String xml = "<m:bodyResult xmlns:m=\"http://db.com\"/>" ; 52 InputStream is = new ByteArrayInputStream (xml.getBytes()); 53 SOAPBodyElement result = new SOAPBodyElement(is); 54 return new SOAPBodyElement [] { result }; 55 } 56 57 public Element [] testElement(Element [] bodyElems) 58 throws Exception { 59 if (bodyElems == null || bodyElems.length != 1) { 60 throw new AxisFault("Wrong number of Elements in array!"); 61 } 62 Element el = bodyElems[0]; 63 if (el == null) { 64 throw new AxisFault("Null Element in array!"); 65 } 66 if (!"http://db.com".equals(el.getNamespaceURI())) { 67 throw new AxisFault("Wrong namespace for Element (was \"" + 68 el.getNamespaceURI() + "\" should be " + 69 "\"http://db.com\"!"); 70 } 71 String xml = "<m:elementResult xmlns:m=\"http://db.com\"/>" ; 72 Document doc = XMLUtils.newDocument( 73 new ByteArrayInputStream (xml.getBytes())); 74 Element result = doc.getDocumentElement(); 75 return new Element [] { result }; 76 } 77 78 public Element [] testElementEcho(Element [] bodyElems) 79 throws Exception { 80 return bodyElems; 81 } 82 83 public void testEnvelope(SOAPEnvelope req, SOAPEnvelope resp) 84 throws Exception { 85 SOAPBodyElement body = req.getFirstBody(); 87 resp.addBodyElement(body); 88 resp.addHeader(new SOAPHeaderElement("http://db.com", "local", "value")); 89 } 90 } 91 | Popular Tags |