use of jakarta.xml.ws.wsaddressing.W3CEndpointReference in project metro-jax-ws by eclipse-ee4j.
the class EPRTest method test.
public void test() {
Test proxy = new TestService().getTestPort();
W3CEndpointReferenceBuilder eprbuilder = new W3CEndpointReferenceBuilder();
String address = "http://example.com";
eprbuilder.address(address);
W3CEndpointReference epr = eprbuilder.build();
W3CEndpointReference ret = proxy.test(epr);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ret.writeTo(new StreamResult(baos));
String retEprStr = new String(baos.toByteArray());
assertTrue(retEprStr.contains(address));
}
use of jakarta.xml.ws.wsaddressing.W3CEndpointReference in project metro-jax-ws by eclipse-ee4j.
the class W3CEPRTest method testEPRWithReferenceParameters.
public void testEPRWithReferenceParameters() throws Exception {
W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
builder = builder.address(getEndpointAddress());
DOMSource domsrc = makeDOMSource(xmlInterfaceName);
Document document = (Document) domsrc.getNode();
builder = builder.metadata(document.getDocumentElement());
builder = builder.serviceName(SERVICE_QNAME);
builder = builder.endpointName(PORT_QNAME);
// builder = builder.wsdlDocumentLocation(wsdlurl.toString());
domsrc = makeDOMSource(xmlRefParam1);
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();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
epr.writeTo(new StreamResult(baos));
AddNumbersService service = new AddNumbersService();
AddNumbersPortType myport = (AddNumbersPortType) service.getPort(epr, AddNumbersPortType.class, new AddressingFeature(true, true));
myport.addNumbers(10, 10);
}
use of jakarta.xml.ws.wsaddressing.W3CEndpointReference in project metro-jax-ws by eclipse-ee4j.
the class HelloLiteralTest method testEchoArray.
// Tests epr overriding
// epr(1 reference parameter) passed as argument overrides epr in wsdl(2 reference parameters)
public void testEchoArray() 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 endpointAddress = (String) ((BindingProvider) stub).getRequestContext().get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
W3CEndpointReferenceBuilder eprBuilder = new W3CEndpointReferenceBuilder();
eprBuilder.address(endpointAddress);
eprBuilder.referenceParameter((Element) n1.getFirstChild());
W3CEndpointReference epr = eprBuilder.build();
Hello_Service service = new Hello_Service();
Hello newStub = service.getPort(epr, Hello.class);
String[] in = { "JAXRPC 1.0", "JAXRPC 1.1", "JAXRPC 1.1.2", "JAXRPC 2.0" };
NameType nt = new NameType();
nt.getName().add(in[0]);
nt.getName().add(in[1]);
nt.getName().add(in[2]);
nt.getName().add(in[3]);
jakarta.xml.ws.Holder<NameType> req = new jakarta.xml.ws.Holder<NameType>(nt);
newStub.echoArray(req);
assertTrue(req.value == null);
} catch (Exception e) {
e.printStackTrace();
assertTrue(false);
}
}
use of jakarta.xml.ws.wsaddressing.W3CEndpointReference in project metro-jax-ws by eclipse-ee4j.
the class EndpointEPRTest method testW3CEPR.
public void testW3CEPR() throws Exception {
int port = PortAllocator.getFreePort();
String address = "http://localhost:" + port + "/hello";
Endpoint endpoint = Endpoint.create(new RpcLitEndpoint());
List<Source> metadata = new ArrayList<Source>();
ClassLoader cl = Thread.currentThread().getContextClassLoader();
String[] docs = { "RpcLitEndpoint.wsdl", "RpcLitAbstract.wsdl", "RpcLitEndpoint.xsd" };
for (String doc : docs) {
URL url = cl.getResource(doc);
metadata.add(new StreamSource(url.openStream(), url.toExternalForm()));
}
endpoint.setMetadata(metadata);
endpoint.publish(address);
W3CEndpointReference epr = endpoint.getEndpointReference(W3CEndpointReference.class);
endpoint.stop();
EprUtil.validateEPR(epr, address, null, /*serviceName*/
null, /*portName*/
null, /*portTypeName*/
Boolean.FALSE);
printEPR(epr);
}
Aggregations