1 16 22 23 package test.wsdl.qualify; 24 25 import junit.framework.AssertionFailedError; 26 import org.apache.axis.Message; 27 import org.apache.axis.MessageContext; 28 import org.apache.axis.message.SOAPEnvelope; 29 import org.w3c.dom.Element ; 30 import org.w3c.dom.Node ; 31 32 import javax.xml.rpc.ServiceException ; 33 34 public class Qualify_ServiceTestCase extends junit.framework.TestCase { 35 36 public static final String namespace = "urn:qualifyTest"; 37 38 public Qualify_ServiceTestCase(String name) { 39 super(name); 40 } 41 42 public void test1QualifySimple() { 43 Qualify_ServiceLocator locator = new Qualify_ServiceLocator(); 44 Qualify_BindingStub binding; 45 try { 46 binding = (Qualify_BindingStub)locator.getQualify(); 47 } catch (javax.xml.rpc.ServiceException jre) { 48 throw new AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 49 } 50 assertTrue("binding is null", binding != null); 51 52 try { 53 String value = null; 54 String name = "Tommy"; 55 value = binding.simple(name); 56 57 MessageContext mc = null; 60 mc = binding._getCall().getMessageContext(); 61 Message response = mc.getResponseMessage(); 62 SOAPEnvelope env = response.getSOAPEnvelope(); 63 String responseString = response.getSOAPPartAsString(); 64 65 Element body; 66 try { 67 body = env.getFirstBody().getAsDOM(); 68 } catch (Exception e) { 69 throw new AssertionFailedError("Unable to get request body as DOM Element on server"); 70 } 71 72 75 81 82 String simpleNS = body.getNamespaceURI(); 84 assertEquals("Namespace of Simple element incorrect", simpleNS, namespace); 85 86 Node nameNode = body.getFirstChild(); 87 String nameNS = nameNode.getNamespaceURI(); 88 assertEquals("Namespace of <name> element incorrect", 89 nameNS, namespace); 90 91 assertEquals(value, "Hello there: " + name); 93 94 } catch (java.rmi.RemoteException re) { 95 throw new AssertionFailedError("Remote Exception caught: " + re); 96 } 97 } 98 99 public void test2QualifyFormOverride() { 100 Qualify_ServiceLocator locator = new Qualify_ServiceLocator(); 101 test.wsdl.qualify.Qualify_BindingStub binding; 102 try { 103 binding = (test.wsdl.qualify.Qualify_BindingStub)locator.getQualify(); 104 } catch (javax.xml.rpc.ServiceException jre) { 105 throw new AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 106 } 107 assertTrue("binding is null", binding != null); 108 109 try { 110 FormOverrideResponseResponse value = null; 111 FormOverrideComplex arg = new FormOverrideComplex(); 112 arg.setName("Timmah"); 113 value = binding.formOverride(arg); 114 115 MessageContext mc = null; 119 mc = binding._getCall().getMessageContext(); 120 Message response = mc.getResponseMessage(); 121 SOAPEnvelope env = response.getSOAPEnvelope(); 122 String responseString = response.getSOAPPartAsString(); 123 124 Element body; 125 try { 126 body = env.getFirstBody().getAsDOM(); 127 } catch (Exception e) { 128 throw new AssertionFailedError("Unable to get request body as DOM Element on server"); 129 } 130 131 134 142 143 String FormOverrideNS = body.getNamespaceURI(); 145 assertEquals("Namespace of <FormOverrideResponse> element incorrect", 146 FormOverrideNS, namespace); 147 148 Node complexNode = body.getFirstChild(); 149 String complexNS = complexNode.getNamespaceURI(); 150 assertNull("Namespace of <complex> element incorrect", complexNS); 151 152 if (complexNode.hasChildNodes()) { 156 Node nameNode = complexNode.getFirstChild(); 157 String nameNS = nameNode.getNamespaceURI(); 158 assertEquals("Namespace of <name> element incorrect", 159 nameNS, namespace); 160 } 161 162 assertEquals(value.getName(), "Tommy"); 164 } catch (java.rmi.RemoteException re) { 165 throw new AssertionFailedError("Remote Exception caught: " + re); 166 } 167 } 168 169 } 170 171 | Popular Tags |