use of com.sun.xml.ws.api.addressing.WSEndpointReference 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.api.addressing.WSEndpointReference in project metro-jax-ws by eclipse-ee4j.
the class ReferenceParametersTest method testReferenceParametersConversion2.
public void testReferenceParametersConversion2() throws Exception {
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
docFactory.setNamespaceAware(true);
DocumentBuilder db = docFactory.newDocumentBuilder();
Document doc = db.newDocument();
Element el1 = doc.createElementNS("http:foo.bar", "Element1");
Element el2 = doc.createElementNS("http:foo.bar", "Element1");
W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
EndpointReference epr = builder.address("http://foo.bar").referenceParameter(el1).referenceParameter(el2).build();
System.out.println("EPR " + epr);
WSEndpointReference wsepr = new WSEndpointReference(epr);
MemberSubmissionEndpointReference translated = wsepr.toSpec(MemberSubmissionEndpointReference.class);
assert (translated.referenceParameters.elements.size() == 2);
}
use of com.sun.xml.ws.api.addressing.WSEndpointReference in project metro-jax-ws by eclipse-ee4j.
the class WSEndpointReferenceTest method testAddress.
public void testAddress() throws Exception {
WSEndpointReference epr = createEPR();
assertEquals("http://example.com/fabrikam/acct", epr.getAddress());
}
use of com.sun.xml.ws.api.addressing.WSEndpointReference in project metro-jax-ws by eclipse-ee4j.
the class WSEndpointReferenceTest method creaateSubtreeEPR.
/**
* This creates {@link WSEndpointReference} that uses a fragment infoset.
* We should really fix this in XMLStreamBuffer.
*/
private WSEndpointReference creaateSubtreeEPR() throws XMLStreamException {
XMLStreamBuffer xsb = XMLStreamBuffer.createNewBufferFromXMLStreamReader(XMLInputFactory.newInstance().createXMLStreamReader(getClass().getClassLoader().getResourceAsStream("test-epr.xml")));
StreamReaderBufferProcessor p = xsb.readAsXMLStreamReader();
XMLStreamBuffer mark = p.nextTagAndMark();
return new WSEndpointReference(mark, W3C);
}
use of com.sun.xml.ws.api.addressing.WSEndpointReference in project metro-jax-ws by eclipse-ee4j.
the class WSDLEprExtensionsTest method testEprWithDispatchWithoutWSDL.
/**
* Tests client-side access to EPR extensions specified in WSDL
* @throws Exception
*/
public void testEprWithDispatchWithoutWSDL() throws Exception {
Service service = Service.create(serviceName);
service.addPort(portName, jakarta.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING, endpointAddress);
Dispatch dispatch = service.createDispatch(portName, Source.class, Service.Mode.PAYLOAD);
WSEndpointReference wsepr = ((WSBindingProvider) dispatch).getWSEndpointReference();
assertTrue(wsepr.getEPRExtensions().isEmpty());
}
Aggregations