use of com.sun.xml.ws.message.saaj.SAAJMessage in project metro-jax-ws by eclipse-ee4j.
the class GenerateToElementTest method testCorrectToFromResMsg.
public void testCorrectToFromResMsg() throws Exception {
String reqMsgStr = "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:a=\"http://www.w3.org/2005/08/addressing\">" + "<s:Header>" + "<a:Action s:mustUnderstand=\"1\">http://example.org/action/echoIn</a:Action>" + "<a:ReplyTo s:actor=\"http://www.w3.org/2003/05/soap-envelope/role/none\"><a:Address>http://www.microsoft.com/</a:Address></a:ReplyTo>" + "<a:MessageID>urn:uuid:d715800d-67e2-4254-a86e-e31a1bfaecab</a:MessageID>" + "<a:ReplyTo><a:Address>http://10.244.13.245:8000/2eaddcdf-e10b-41c5-9f1f-a7ac50853fc3/4b1de783-1499-4419-9634-465f8797a0a8</a:Address></a:ReplyTo>" + "<a:To s:mustUnderstand=\"1\">http://scl58353.us.oracle.com:9902/WSAddressingCR_Service_WCF/WSAddressing10.svc/Echo4</a:To>" + "</s:Header>" + "<s:Body>" + "<echoIn xmlns=\"http://example.org/echo\">test1151</echoIn>" + "</s:Body>" + "</s:Envelope>";
String respMsgStr = "<?xml version='1.0' encoding='UTF-8'?>" + "<S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\">" + "<S:Body>" + "<ns0:echoOut xmlns:ns0=\"http://example.org/echo\">test1151</ns0:echoOut>" + "</S:Body>" + "</S:Envelope>";
String finalToFromResponseMsg = "";
WSEndpointReference originalReplyToFromRequestMsg = null;
AddressingVersion av = AddressingVersion.W3C;
SOAPVersion sv = SOAPVersion.SOAP_11;
String action = "http://example.org/action/echoOut";
SAAJMessage reqMsg = new SAAJMessage(makeSOAPMessage(reqMsgStr));
SAAJMessage respMsg = new SAAJMessage(makeSOAPMessage(respMsgStr));
HeaderList requestHdrs = (HeaderList) reqMsg.getHeaders();
originalReplyToFromRequestMsg = requestHdrs.getReplyTo(av, sv);
Packet responsePacket = null;
try {
responsePacket = new Packet(reqMsg).createServerResponse(respMsg, av, sv, action);
} catch (Exception e) {
e.printStackTrace();
}
// check toHeader
finalToFromResponseMsg = AddressingUtils.getTo(responsePacket.getHeaderList(), av, sv);
assertEquals(finalToFromResponseMsg, originalReplyToFromRequestMsg.getAddress());
}
use of com.sun.xml.ws.message.saaj.SAAJMessage in project metro-jax-ws by eclipse-ee4j.
the class SAAJFactory method read.
/**
* Reads the message within the Packet to a SAAJMessage. After this call message is consumed.
* @param packet Packet
* @return Created SAAJPMessage
* @throws SOAPException if SAAJ processing fails
*/
public static SAAJMessage read(Packet packet) throws SOAPException {
SAAJFactory saajfac = packet.getSAAJFactory();
if (saajfac != null) {
SAAJMessage msg = saajfac.readAsSAAJ(packet);
if (msg != null)
return msg;
}
// Use the Component from the Packet if it exists. Note the logic
// in the ServiceFinder is such that find(Class) is not equivalent
// to find (Class, null), so the ternary operator is needed.
ServiceFinder<SAAJFactory> factories = (packet.component != null ? ServiceFinder.find(SAAJFactory.class, packet.component) : ServiceFinder.find(SAAJFactory.class));
for (SAAJFactory s : factories) {
SAAJMessage msg = s.readAsSAAJ(packet);
if (msg != null)
return msg;
}
return instance.readAsSAAJ(packet);
}
use of com.sun.xml.ws.message.saaj.SAAJMessage in project metro-jax-ws by eclipse-ee4j.
the class SOAPFaultBuilder1Test method testFault1.
public void testFault1() throws Throwable {
SOAPMessage msg = SOAPVersion.SOAP_11.getMessageFactory().createMessage(null, new ByteArrayInputStream(fault1.getBytes()));
SOAPFaultBuilder sfb = SOAPFaultBuilder.create(new SAAJMessage(msg));
Throwable t = sfb.createException(null);
assertTrue(t instanceof SOAPFaultException);
assertTrue(t.getMessage().contains("Client received SOAP Fault from server:"));
}
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 testReferenceParametersNsDecl.
/**
* Test where NS decl for ReferenceParameters is on the SOAP envelope
* @throws Exception
*/
public void testReferenceParametersNsDecl() throws Exception {
String xmlRefParam1 = "<myns:MyParam1 wsa:IsReferenceParameter='true' xmlns:wsa=\"http://www.w3.org/2005/08/addressing\">Hello</myns:MyParam1>";
String xmlRefParam2 = "<myns:MyParam2 wsa:IsReferenceParameter='true' 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/\" xmlns:myns=\"http://cptestservice.org/wsdl\"><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);
assertEquals("NS Decl did not match", "http://cptestservice.org/wsdl", e.getNamespaceURI());
}
}
Aggregations