code_junkie

How do I add a namespace reference to a SOAP response with Apache Axis2 and WSDL2Java

Nov 10th, 2011
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
  2. <soapenv:Body>
  3. <ns1:CreateEntityTypesResponse xmlns:ns1="http://somedomain.com/wsinterface">
  4. <newKeys>
  5. <value>1234</value>
  6. </newKeys>
  7. <newKeys>
  8. <value>2345</value>
  9. </newKeys>
  10. <newKeys>
  11. <value>3456</value>
  12. </newKeys>
  13. <newKeys xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
  14. <newKeys xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
  15. <errors>Error1</errors>
  16. <errors>Error2</errors>
  17. </ns1:CreateEntityTypesResponse>
  18. </soapenv:Body>
  19. </soapenv:Envelope>
  20.  
  21. // create SOAP envelope with that payload
  22. org.apache.axiom.soap.SOAPEnvelope env = null;
  23. env = toEnvelope(
  24. getFactory(_operationClient.getOptions().getSoapVersionURI()),
  25. methodName,
  26. optimizeContent(new javax.xml.namespace.QName
  27. ("http://tempuri.org/","methodName")));
  28.  
  29. //adding SOAP soap_headers
  30. _serviceClient.addHeadersToEnvelope(env);
  31.  
  32. OMNamespace xsi = getFactory(_operationClient.getOptions().getSoapVersionURI()).
  33. createOMNamespace("http://www.w3.org/2001/XMLSchema-instance", "xsi");
  34.  
  35. env.declareNamespace(xsi);
  36.  
  37. SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
  38. SOAPEnvelope envelope = fac.getDefaultEnvelope();
  39. OMNamespace xsi = fac.createOMNamespace("http://www.w3.org/2001/XMLSchema-instance", "xsi");
  40.  
  41. envelope.declareNamespace(xsi);
  42. OMNamespace methodNs = fac.createOMNamespace("http://somedomain.com/wsinterface", "ns1");
  43.  
  44. OMElement method = fac.createOMElement("CreateEntityTypesResponse", methodNs);
  45.  
  46. //add the newkeys and errors as OMElements here...
Add Comment
Please, Sign In to add comment