use of com.sun.xml.ws.message.saaj.SAAJMessage in project metro-jax-ws by eclipse-ee4j.
the class ReferenceParametersTest method testReferenceParameters2.
public void testReferenceParameters2() throws Exception {
String xmlParam1 = "<myns:MyParam1 xmlns:myns=\"http://cptestservice.org/wsdl\">Hello</myns:MyParam1>";
String xmlParam2 = "<myns:MyParam2 xmlns:myns=\"http://cptestservice.org/wsdl\"><myns:InnerEl> Hello Hello </myns:InnerEl></myns:MyParam2>";
String request = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\"><S:Body><DataType xmlns=\"http://cptestservice.org/xsd\"><param>foo bar</param></DataType></S:Body></S:Envelope>";
MessageFactory messageFactory = MessageFactory.newInstance();
MimeHeaders headers = new MimeHeaders();
headers.addHeader("Content-Type", "text/xml");
SOAPMessage soapMsg = messageFactory.createMessage(headers, new ByteArrayInputStream(request.getBytes()));
Packet p = new Packet(new SAAJMessage(soapMsg));
List<Element> refparams = new ArrayList<Element>();
Node n1 = DOMUtil.createDOMNode(new ByteArrayInputStream(xmlParam1.getBytes()));
Node n2 = DOMUtil.createDOMNode(new ByteArrayInputStream(xmlParam2.getBytes()));
refparams.add((Element) n1.getFirstChild());
refparams.add((Element) n2.getFirstChild());
WSEndpointReference wsepr = new WSEndpointReference(AddressingVersion.W3C, "http://foo.bar", null, null, null, null, null, refparams);
wsepr.addReferenceParametersToList(p.getMessage().getHeaders());
// p.getMessage().writeTo(XMLOutputFactory.newInstance().createXMLStreamWriter(System.out));
List<Element> refParams = p.getReferenceParameters();
assertEquals("Did n't get expected ReferenceParameters", 2, refParams.size());
for (Element e : refParams) {
assertTrue("isReferenceParameter attribute not present on header", e.getAttributeNodeNS(W3CAddressingConstants.WSA_NAMESPACE_NAME, "IsReferenceParameter") != null);
}
}
use of com.sun.xml.ws.message.saaj.SAAJMessage in project metro-jax-ws by eclipse-ee4j.
the class ReferenceParametersTest method testReplyToReferenceParameters.
/**
* See if the ReferenceParamaters get added properly from ReplyTo EPR to response
* @throws Exception
*/
public void testReplyToReferenceParameters() throws Exception {
String requestStr = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:user=\"http://foo.bar\" xmlns:wsa=\"http://www.w3.org/2005/08/addressing\">" + "<S:Header>" + "<wsa:Action>http://example.org/action/echoIn</wsa:Action>" + "<wsa:To>http://www.w3.org/2005/08/addressing/anonymous</wsa:To>" + "<wsa:MessageID>urn:uuid:1234567890</wsa:MessageID>" + "<wsa:ReplyTo>" + "<wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>" + "<wsa:ReferenceParameters>" + "<user:foo wsa:IsReferenceParameter='true'>bar</user:foo>" + "<user:bar>" + "<user:foobar>barfoo</user:foobar>" + "</user:bar>" + "</wsa:ReferenceParameters>" + "</wsa:ReplyTo>" + "</S:Header>" + "<S:Body><DataType xmlns=\"http://foo.org/xsd\"><param>foo bar</param></DataType></S:Body></S:Envelope>";
MessageFactory messageFactory = MessageFactory.newInstance();
MimeHeaders headers = new MimeHeaders();
headers.addHeader("Content-Type", "text/xml");
SOAPMessage soapMsg = messageFactory.createMessage(headers, new ByteArrayInputStream(requestStr.getBytes()));
Message message = new SAAJMessage(soapMsg);
WSEndpointReference wsepr = message.getHeaders().getReplyTo(AddressingVersion.W3C, SOAPVersion.SOAP_11);
String responseStr = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\"><S:Body><DataTypeResponse xmlns=\"http://cptestservice.org/xsd\"><param>foo bar</param></DataTypeResponse></S:Body></S:Envelope>";
MimeHeaders headers1 = new MimeHeaders();
headers1.addHeader("Content-Type", "text/xml");
SOAPMessage soapMsg1 = messageFactory.createMessage(headers1, new ByteArrayInputStream(responseStr.getBytes()));
Message m2 = new SAAJMessage(soapMsg1);
wsepr.addReferenceParametersToList(m2.getHeaders());
Packet response = new Packet(m2);
List<Element> refParams = response.getReferenceParameters();
assertEquals("Did n't get expected ReferenceParameters", 2, refParams.size());
for (Element e : refParams) {
assertTrue("isReferenceParameter attribute not present on header", e.getAttributeNodeNS(W3CAddressingConstants.WSA_NAMESPACE_NAME, "IsReferenceParameter") != null);
assertEquals("NS Decl did not match", "http://foo.bar", e.getNamespaceURI());
}
}
use of com.sun.xml.ws.message.saaj.SAAJMessage in project metro-jax-ws by eclipse-ee4j.
the class ReferenceParametersTest method testReferenceParameters1.
public void testReferenceParameters1() throws Exception {
String xmlRefParam1 = "<myns:MyParam1 wsa:IsReferenceParameter='true' xmlns:myns=\"http://cptestservice.org/wsdl\" xmlns:wsa=\"http://www.w3.org/2005/08/addressing\">Hello</myns:MyParam1>";
String xmlRefParam2 = "<myns:MyParam2 wsa:IsReferenceParameter='true' xmlns:myns=\"http://cptestservice.org/wsdl\" xmlns:wsa=\"http://www.w3.org/2005/08/addressing\">There</myns:MyParam2>";
String request = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\"><S:Header>" + xmlRefParam1 + xmlRefParam2 + "</S:Header><S:Body><DataType xmlns=\"http://cptestservice.org/xsd\"><param>foo bar</param></DataType></S:Body></S:Envelope>";
MessageFactory messageFactory = MessageFactory.newInstance();
MimeHeaders headers = new MimeHeaders();
headers.addHeader("Content-Type", "text/xml");
SOAPMessage soapMsg = messageFactory.createMessage(headers, new ByteArrayInputStream(request.getBytes()));
// soapMsg.writeTo(System.out);
Packet p = new Packet(new SAAJMessage(soapMsg));
List<Element> refParams = p.getReferenceParameters();
assertEquals("Did n't get expected ReferenceParameters", 2, refParams.size());
for (Element e : refParams) {
assertTrue("isReferenceParameter attribute not present on header", e.getAttributeNodeNS(W3CAddressingConstants.WSA_NAMESPACE_NAME, "IsReferenceParameter") != null);
}
}
use of com.sun.xml.ws.message.saaj.SAAJMessage in project metro-jax-ws by eclipse-ee4j.
the class ReferenceParametersTest method testReferenceParameters2.
public void testReferenceParameters2() throws Exception {
String xmlParam1 = "<myns:MyParam1 xmlns:myns=\"http://cptestservice.org/wsdl\">Hello</myns:MyParam1>";
String xmlParam2 = "<myns:MyParam2 xmlns:myns=\"http://cptestservice.org/wsdl\"><myns:InnerEl> Hello Hello </myns:InnerEl></myns:MyParam2>";
String request = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\"><S:Body><DataType xmlns=\"http://cptestservice.org/xsd\"><param>foo bar</param></DataType></S:Body></S:Envelope>";
MessageFactory messageFactory = MessageFactory.newInstance();
MimeHeaders headers = new MimeHeaders();
headers.addHeader("Content-Type", "text/xml");
SOAPMessage soapMsg = messageFactory.createMessage(headers, new ByteArrayInputStream(request.getBytes()));
Packet p = new Packet(new SAAJMessage(soapMsg));
List<Element> refparams = new ArrayList<Element>();
Node n1 = DOMUtil.createDOMNode(new ByteArrayInputStream(xmlParam1.getBytes()));
Node n2 = DOMUtil.createDOMNode(new ByteArrayInputStream(xmlParam2.getBytes()));
refparams.add((Element) n1.getFirstChild());
refparams.add((Element) n2.getFirstChild());
WSEndpointReference wsepr = new WSEndpointReference(AddressingVersion.W3C, "http://foo.bar", null, null, null, null, null, refparams);
wsepr.addReferenceParametersToList(p.getMessage().getHeaders());
// p.getMessage().writeTo(XMLOutputFactory.newInstance().createXMLStreamWriter(System.out));
List<Element> refParams = p.getReferenceParameters();
assertEquals("Did n't get expected ReferenceParameters", 2, refParams.size());
for (Element e : refParams) {
assertTrue("isReferenceParameter attribute not present on header", e.getAttributeNodeNS(W3CAddressingConstants.WSA_NAMESPACE_NAME, "IsReferenceParameter") != null);
}
}
use of com.sun.xml.ws.message.saaj.SAAJMessage in project metro-jax-ws by eclipse-ee4j.
the class DomUtilTester method testSOAPEnvelope2.
public void testSOAPEnvelope2() throws Exception {
for (File f : folder.listFiles()) {
System.out.println("***********" + f.getName() + "***********");
SOAPMessage soapmsg = getSOAPMessage(f);
SAAJMessage saajmessage = new SAAJMessage(soapmsg);
XMLStreamWriter writer = XMLStreamWriterFactory.create(System.out);
saajmessage.writeTo(writer);
writer.close();
assert (true);
System.out.println("*****************************************");
}
}
Aggregations