use of jakarta.xml.ws.wsaddressing.W3CEndpointReferenceBuilder in project metro-jax-ws by eclipse-ee4j.
the class EprMarshalUnmarshalTest method testW3CEPRBuilder.
public void testW3CEPRBuilder() throws Exception {
try {
String xmlParam1 = "<myns:MyParam1 xmlns:myns=\"http://cptestservice.org/wsdl\">Hello</myns:MyParam1>";
Node n1 = DOMUtil.createDOMNode(new ByteArrayInputStream(xmlParam1.getBytes()));
String metadata = "<myMetadata>This is not useful metadata</myMetadata>";
Node n2 = createDOMNodeNoNS(new ByteArrayInputStream(metadata.getBytes()));
W3CEndpointReferenceBuilder eprBuilder = new W3CEndpointReferenceBuilder();
eprBuilder.address(endpointAddress);
eprBuilder.referenceParameter((Element) n1.getFirstChild());
eprBuilder.metadata((Element) n2.getFirstChild());
W3CEndpointReference epr = eprBuilder.build();
epr.writeTo(new StreamResult(System.out));
} catch (Exception e) {
e.printStackTrace();
assertTrue(false);
}
}
use of jakarta.xml.ws.wsaddressing.W3CEndpointReferenceBuilder in project metro-jax-ws by eclipse-ee4j.
the class ReferenceParametersTest method testReferenceParametersConversion1.
/*
* Whitebox test for issue564
*/
/*
This test has been moved to jaxws-unit test harness so that 2.1.5 tag can be used.
public void testFaultToReferenceParametersJAXBMessage2() throws Exception {
String requestStr = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<S:Envelope xmlns:S=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:user=\"http://foo.bar\" " +
"xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/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://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>" +
"<wsa:ReferenceParameters>" +
"<user:foo>bar</user:foo>" +
"<user:bar xmlns:user=\"http://foo.bar\">" +
"<user:foobar>barfoo</user:foobar>" +
"</user:bar>" +
"</wsa:ReferenceParameters>" +
"</wsa:ReplyTo>" +
"<wsa:FaultTo>" +
"<wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>" +
"<wsa:ReferenceParameters>" +
"<user:foo>bar</user:foo>" +
"<user:bar xmlns:user=\"http://foo.bar\">" +
"<user:foobar>barfoo</user:foobar>" +
"</user:bar>" +
"</wsa:ReferenceParameters>" +
"</wsa:FaultTo>" +
"</S:Header>" +
"<S:Body>" +
"<addNumbers xmlns=\"http://example.com/\">" +
"<number1>10</number1>" +
"<number2>10</number2>" +
"</addNumbers>" +
"</S:Body></S:Envelope>";
Message message = useStream12Codec(requestStr);
WSEndpointReference wsepr = message.getHeaders().getFaultTo(AddressingVersion.MEMBER, SOAPVersion.SOAP_12);
Message m2 = Messages.create("Test Unsupported",AddressingVersion.MEMBER,SOAPVersion.SOAP_12);
wsepr.addReferenceParameters(m2.getHeaders());
ByteArrayBuffer baos = new ByteArrayBuffer();
XMLStreamWriter writer = XMLStreamWriterFactory.create(baos);
m2.writeTo(writer);
writer.flush();
XMLInputFactory readerFactory = XMLInputFactory.newInstance();
XMLStreamReader reader = readerFactory.createXMLStreamReader(baos.newInputStream());
Message sm = Messages.create(reader);
Packet sm_packet = new Packet(sm);
List<Element> refParams = sm_packet.getReferenceParameters();
assertEquals("Did n't get expected ReferenceParameters",2,refParams.size());
for(Element e: refParams) {
assertEquals("NS Decl did not match", "http://foo.bar", e.getNamespaceURI());
}
}
*/
public void testReferenceParametersConversion1() 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");
W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
EndpointReference epr = builder.address("http://foo.bar").referenceParameter(el1).build();
System.out.println("EPR " + epr);
WSEndpointReference wsepr = new WSEndpointReference(epr);
MemberSubmissionEndpointReference translated = wsepr.toSpec(MemberSubmissionEndpointReference.class);
// System.out.println(translated);
assert (translated.referenceParameters.elements.size() == 1);
}
use of jakarta.xml.ws.wsaddressing.W3CEndpointReferenceBuilder in project metro-jax-ws by eclipse-ee4j.
the class ReferenceParametersTest method testReferenceParametersConversion3.
public void testReferenceParametersConversion3() 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");
Element el3 = doc.createElementNS("http:foo.bar", "Element1");
W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
EndpointReference epr = builder.address("http://foo.bar").referenceParameter(el1).referenceParameter(el2).referenceParameter(el3).build();
System.out.println("EPR " + epr);
WSEndpointReference wsepr = new WSEndpointReference(epr);
MemberSubmissionEndpointReference translated = wsepr.toSpec(MemberSubmissionEndpointReference.class);
assert (translated.referenceParameters.elements.size() == 3);
}
use of jakarta.xml.ws.wsaddressing.W3CEndpointReferenceBuilder 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 jakarta.xml.ws.wsaddressing.W3CEndpointReferenceBuilder in project metro-jax-ws by eclipse-ee4j.
the class W3CEPRTest method testW3CEprBuilder_withWSDL_ServiceName.
public void testW3CEprBuilder_withWSDL_ServiceName() throws Exception {
W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
builder = builder.address(getEndpointAddress());
builder = builder.serviceName(SERVICE_QNAME);
builder = builder.endpointName(PORT_QNAME);
builder = builder.wsdlDocumentLocation(getEndpointAddress() + "?wsdl");
DOMSource domsrc = makeDOMSource(xmlRefParam1);
Document document = (Document) domsrc.getNode();
builder = builder.referenceParameter(document.getDocumentElement());
domsrc = makeDOMSource(xmlRefParam2);
document = (Document) domsrc.getNode();
builder = builder.referenceParameter(document.getDocumentElement());
W3CEndpointReference epr = builder.build();
DOMResult result = new DOMResult();
epr.writeTo(result);
assertTrue(EprUtil.validateEPR(result.getNode(), W3CEndpointReference.class, getEndpointAddress(), SERVICE_QNAME, PORT_QNAME, null, getEndpointAddress() + "?wsdl"));
// ByteArrayOutputStream baos = new ByteArrayOutputStream();
// epr.writeTo(new StreamResult(baos));
// baos.writeTo(System.out);
}
Aggregations