use of com.sun.xml.ws.util.ByteArrayBuffer in project metro-jax-ws by eclipse-ee4j.
the class SAAJMessageTester method writeMessage.
private void writeMessage(InputStream in) throws Exception {
MessageFactory mf = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
MimeHeaders mhs = new MimeHeaders();
mhs.addHeader("Content-Type", "text/xml");
mhs.addHeader("Content-Transfer-Encoding", "binary");
SOAPMessage sm = mf.createMessage(mhs, in);
SAAJMessage msg = new SAAJMessage(sm);
ByteArrayBuffer baos = new ByteArrayBuffer();
XMLStreamWriter writer = XMLStreamWriterFactory.create(baos);
msg.writeTo(writer);
writer.flush();
}
use of com.sun.xml.ws.util.ByteArrayBuffer in project metro-jax-ws by eclipse-ee4j.
the class SAAJMessageTester method testDOMLevel1WriteTo.
public void testDOMLevel1WriteTo() throws Exception {
DocumentBuilderFactory builderFactory = null;
DocumentBuilder builder = null;
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage soapMessage = messageFactory.createMessage();
SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope();
soapEnvelope.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
soapEnvelope.setAttribute("xmlns:xsd", "http://www.w3.org/2001/XMLSchema");
SOAPBody soapBody = soapEnvelope.getBody();
Name elementName = soapEnvelope.createName("addNumbers", "", "http://duke.org");
SOAPBodyElement bodyElement = soapBody.addBodyElement(elementName);
SAAJMessage msg = new SAAJMessage(soapMessage);
ByteArrayBuffer baos = new ByteArrayBuffer();
XMLStreamWriter writer = XMLStreamWriterFactory.createXMLStreamWriter(baos);
msg.writeTo(writer);
writer.flush();
}
use of com.sun.xml.ws.util.ByteArrayBuffer in project metro-jax-ws by eclipse-ee4j.
the class SerializableWebServiceExceptionTest method testClientTransportExSerial3.
/**
* Tests argument with null
* @throws Exception
*/
public void testClientTransportExSerial3() throws Exception {
WebServiceException wse_orig = new ClientTransportException(ClientMessages.localizableFAILED_TO_PARSE(new URL("http://example.com?wsdl"), null));
ClientTransportException cte_orig = (ClientTransportException) wse_orig;
ByteArrayBuffer buffer = new ByteArrayBuffer();
ObjectOutputStream oos = new ObjectOutputStream(buffer);
oos.writeObject(wse_orig);
ObjectInputStream ois = new ObjectInputStream(buffer.newInputStream());
WebServiceException wse_ser = (WebServiceException) ois.readObject();
ObjectInputStream ois1 = new ObjectInputStream(buffer.newInputStream());
ClientTransportException cte_ser = (ClientTransportException) ois1.readObject();
assertEquals(cte_orig.getLocalizedMessage(), cte_ser.getLocalizedMessage());
assertEquals(cte_orig.getResourceBundleName(), cte_ser.getResourceBundleName());
assertEquals(cte_orig.getKey(), cte_ser.getKey());
assert (cte_orig.getArguments().length == cte_ser.getArguments().length);
assertEquals(cte_orig.getArguments()[0], cte_ser.getArguments()[0]);
assertEquals(cte_orig.getArguments()[1], cte_ser.getArguments()[1]);
}
use of com.sun.xml.ws.util.ByteArrayBuffer in project metro-jax-ws by eclipse-ee4j.
the class EPRWriteNReadTest method verifyEPR.
private static void verifyEPR(WSEndpointReference wsepr) throws Exception {
ByteArrayBuffer bytebuffer = new ByteArrayBuffer();
XMLStreamWriter w = XMLOutputFactory.newInstance().createXMLStreamWriter(bytebuffer);
System.out.println("----------------------------------------------------------------------");
w.writeStartDocument();
wsepr.writeTo("EndpointReference", w);
w.writeEndDocument();
System.out.println(bytebuffer.toString());
// verify the validity of infoset by reading it as EPR back again
EndpointReference epr = W3CEndpointReference.readFrom(new StreamSource(bytebuffer.newInputStream()));
// Verify it good old way
XMLStreamReader xsr = XMLInputFactory.newInstance().createXMLStreamReader(new StreamSource(bytebuffer.newInputStream()));
QName q = new QName("http://schemas.xmlsoap.org/ws/2006/02/addressingidentity", "Identity");
while (xsr.hasNext()) {
xsr.next();
if (xsr.getEventType() == XMLStreamConstants.START_ELEMENT && xsr.getLocalName().equals("Identity")) {
assertEquals(q.getNamespaceURI(), xsr.getNamespaceURI());
}
}
}
use of com.sun.xml.ws.util.ByteArrayBuffer in project metro-jax-ws by eclipse-ee4j.
the class StreamMessageTest method testMessageWriteTo1.
public void testMessageWriteTo1() throws Exception {
String soapMsg = "<S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\">" + "<S:Header>" + "</S:Header>" + "<S:Body>" + "<GetCountryCodesResponse xmlns='http://www.strikeiron.com'> <GetCountryCodesResult/></GetCountryCodesResponse>" + "</S:Body>" + "</S:Envelope>";
Message message = createSOAP11StreamMessage(soapMsg);
ByteArrayBuffer baos = new ByteArrayBuffer();
XMLStreamWriter writer = XMLStreamWriterFactory.create(baos);
message.writeTo(writer);
writer.flush();
baos.writeTo(System.out);
}
Aggregations