1 16 22 23 package test.wsdl.qualify2; 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.Attr ; 30 import org.w3c.dom.Element ; 31 32 import javax.xml.rpc.ServiceException ; 33 34 public class AttributeQualify_ServiceTestCase extends junit.framework.TestCase { 35 36 public static final String NAMESPACE = "urn:attributeQualify"; 37 38 public AttributeQualify_ServiceTestCase(String name) { 39 super(name); 40 } 41 42 public void test1AttributeQualifyEchoPhone() { 43 test.wsdl.qualify2.AttributeQualify_Port binding; 44 test.wsdl.qualify2.AttributeQualify_ServiceLocator locator = new test.wsdl.qualify2.AttributeQualify_ServiceLocator(); 45 try { 46 binding = locator.getAttributeQualify(); 47 } 48 catch (javax.xml.rpc.ServiceException jre) { 49 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 50 } 51 assertTrue("binding is null", binding != null); 52 53 try { 54 test.wsdl.qualify2.Phone phone = new Phone(); 55 phone.setAge(35); 56 phone.setAreaCode(505); 57 phone.setColor("red"); 58 phone.setExchange("555"); 59 phone.setHair("brown"); 60 phone.setNumber("1212"); 61 62 Phone result = binding.echoPhone(phone); 63 64 assertTrue(result.equals(phone)); 66 67 MessageContext mc = null; 70 try { 71 mc = locator.getCall().getMessageContext(); 72 } catch (ServiceException e) { 73 throw new AssertionFailedError("Unable to get call object from service"); 74 } 75 Message response = mc.getResponseMessage(); 76 SOAPEnvelope env = response.getSOAPEnvelope(); 77 String responseString = response.getSOAPPartAsString(); 78 79 Element body; 80 try { 81 body = env.getFirstBody().getAsDOM(); 82 } catch (Exception e) { 83 throw new AssertionFailedError("Unable to get request body as DOM Element on server"); 84 } 85 86 89 100 String bodyNS = body.getNamespaceURI(); 101 assertEquals("Namespace of body element incorrect", bodyNS, NAMESPACE); 102 103 Attr ageAttr = body.getAttributeNode("age"); 105 assertNull("namespace of attribute 'age' should be null", 106 ageAttr.getNamespaceURI()); 107 108 Attr hairAttr = body.getAttributeNodeNS(NAMESPACE, "hair"); 110 assertNotNull("namespace of attribute 'hair' is not correct", 111 hairAttr); 112 Attr colorAttr = body.getAttributeNodeNS(NAMESPACE, "color"); 113 assertNotNull("namespace of attribute 'color' is not correct", 114 colorAttr); 115 116 } catch (java.rmi.RemoteException re) { 117 throw new AssertionFailedError("Remote Exception caught: " + re); 118 } 119 } 120 121 122 } 123 124 | Popular Tags |