Пример #1
0
  /* This test has been moved to jaxws-unit harness to use tag 2.1.5

  public void testHeadersInStreamMessage() throws Exception {
  	String requestStr = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
              "<S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\" " +
              "xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\" xmlns:user=\"http://foo.bar\">" +
              "<S:Header>" +
              "<user:foo>bar</user:foo>" +
              "</S:Header>" +
              "<S:Body>" +
              "<addNumbers xmlns=\"http://example.com/\">" +
              "<number1>10</number1>" +
              "<number2>10</number2>" +
              "</addNumbers>" +
              "</S:Body></S:Envelope>";
      Message message = useStreamCodec(requestStr);
      HeaderList hl = message.getHeaders();
      ByteArrayBuffer baos = new ByteArrayBuffer();
      XMLStreamWriter writer = XMLStreamWriterFactory.create(baos);
      writer.writeStartDocument();
      for(Header h: hl) {
          h.writeTo(writer);
      }
      writer.writeEndDocument();
      writer.flush();
      //baos.writeTo(System.out);

      XMLInputFactory readerFactory = XMLInputFactory.newInstance();
      XMLStreamReader reader = readerFactory.createXMLStreamReader(baos.newInputStream());
      reader.next();// go to start element
      Header h = Headers.create(SOAPVersion.SOAP_11,reader);
      assertEquals(h.getNamespaceURI(),"http://foo.bar");
  }

  */
  Message useStreamCodec(String msg) throws IOException {
    Codec codec = Codecs.createSOAPEnvelopeXmlCodec(SOAPVersion.SOAP_11);
    Packet packet = new Packet();
    ByteArrayInputStream in = new ByteArrayInputStream(msg.getBytes());
    codec.decode(in, "text/xml", packet);
    return packet.getMessage();
  }
Пример #2
0
 public static boolean isTypeof(Packet packet) {
   return (packet.matchTag(tag) && packet.matchURI(uri));
 }