Пример #1
0
 public Element[] testElement(Element[] bodyElems) throws Exception {
   if (bodyElems == null || bodyElems.length != 1) {
     throw new AxisFault("Wrong number of Elements in array!");
   }
   Element el = bodyElems[0];
   if (el == null) {
     throw new AxisFault("Null Element in array!");
   }
   if (!"http://db.com".equals(el.getNamespaceURI())) {
     throw new AxisFault(
         "Wrong namespace for Element (was \""
             + el.getNamespaceURI()
             + "\" should be "
             + "\"http://db.com\"!");
   }
   String xml = "<m:elementResult xmlns:m=\"http://db.com\"/>";
   Document doc = XMLUtils.newDocument(new ByteArrayInputStream(xml.getBytes()));
   Element result = doc.getDocumentElement();
   return new Element[] {result};
 }
Пример #2
0
  public void testEmptyXMLNS() {
    try {
      MessageContext msgContext = new MessageContext(new AxisServer());
      msgContext.setSOAPConstants(SOAPConstants.SOAP12_CONSTANTS);
      msgContext.setProperty(Constants.MC_NO_OPERATION_OK, Boolean.TRUE);

      String req =
          "<xsd1:A xmlns:xsd1=\"urn:myNamespace\">"
              + "<xsd1:B>"
              + "<xsd1:C>foo bar</xsd1:C>"
              + "</xsd1:B>"
              + "</xsd1:A>";

      StringWriter stringWriter = new StringWriter();
      StringReader reqReader = new StringReader(req);
      InputSource reqSource = new InputSource(reqReader);

      Document document = XMLUtils.newDocument(reqSource);

      String msgString = null;

      SOAPEnvelope msg = new SOAPEnvelope(SOAPConstants.SOAP12_CONSTANTS);
      RPCParam arg1 = new RPCParam("urn:myNamespace", "testParam", document.getFirstChild());
      arg1.setXSITypeGeneration(Boolean.FALSE);

      RPCElement body = new RPCElement("urn:myNamespace", "method1", new Object[] {arg1});
      msg.addBodyElement(body);
      body.setEncodingStyle(Constants.URI_LITERAL_ENC);

      SerializationContext context = new SerializationContext(stringWriter, msgContext);
      msg.output(context);

      msgString = stringWriter.toString();
      assertTrue(msgString.indexOf("xmlns=\"\"") == -1);
    } catch (Exception e) {
      fail(e.getMessage());
    }
  }