use of com.sun.xml.ws.developer.MemberSubmissionEndpointReference in project metro-jax-ws by eclipse-ee4j.
the class EndpointEPRTester method testMSEPR.
public void testMSEPR() throws Exception {
int port = Util.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 = { "WEB-INF/wsdl/RpcLitEndpoint.wsdl", "WEB-INF/wsdl/RpcLitAbstract.wsdl", "WEB-INF/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);
MemberSubmissionEndpointReference epr = endpoint.getEndpointReference(MemberSubmissionEndpointReference.class);
endpoint.stop();
EprUtil.validateEPR(epr, address, serviceName, portName, portTypeName, Boolean.TRUE);
printEPR(epr);
}
use of com.sun.xml.ws.developer.MemberSubmissionEndpointReference in project metro-jax-ws by eclipse-ee4j.
the class AddNumbersClient method testDispatchWithRefParams.
public void testDispatchWithRefParams() throws Exception {
if (ClientServerTestUtil.useLocal()) {
System.out.println("HTTP Transport Only Exiting");
return;
}
String xmlRefParam1 = "<myns1:MyParam1 xmlns:myns1=\"http://cptestservice.org/wsdl\">Hello</myns1:MyParam1>";
String xmlRefParam2 = "<myns2:MyParam2 xmlns:myns2=\"http://cptestservice.org/wsdl\">There</myns2:MyParam2>";
String request = "<?xml version=\"1.0\" ?><S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\"><S:Body><DataType xmlns=\"http://cptestservice.org/xsd\"><param>{0}</param></DataType></S:Body></S:Envelope>";
// W3CEndpointReferenceBuilder eprBuilder = new W3CEndpointReferenceBuilder();
// eprBuilder.address(ENDPOINT_ADDRESS);
// eprBuilder.serviceName(SERVICE_QNAME);
// eprBuilder.endpointName(PORT_QNAME);
List<Element> refParams = new ArrayList<Element>();
Element n1 = (Element) DOMUtil.createDOMNode(new ByteArrayInputStream(xmlRefParam1.getBytes())).getFirstChild();
Element n2 = (Element) DOMUtil.createDOMNode(new ByteArrayInputStream(xmlRefParam2.getBytes())).getFirstChild();
refParams.add(n1);
refParams.add(n2);
// eprBuilder.referenceParameter(n1);
// eprBuilder.referenceParameter(n2);
// W3CEndpointReference epr = eprBuilder.build();
WSEndpointReference wsepr = new WSEndpointReference(AddressingVersion.MEMBER, ENDPOINT_ADDRESS, SERVICE_QNAME, PORT_QNAME, null, null, null, refParams);
MemberSubmissionEndpointReference epr = wsepr.toSpec(MemberSubmissionEndpointReference.class);
printEPR(epr);
URL fakeWsdlUrl = Thread.currentThread().getContextClassLoader().getResource("wsdl/AddNumbersFake.wsdl");
Service service = Service.create(fakeWsdlUrl, SERVICE_QNAME);
JAXBContext jc = createJAXBContext();
Dispatch<Object> dispatch = service.createDispatch(epr, jc, Service.Mode.PAYLOAD, new AddressingFeature());
AddNumbers input = new AddNumbers();
input.setNumber1(2);
input.setNumber2(4);
JAXBElement<AddNumbersResponse> o = (JAXBElement<AddNumbersResponse>) dispatch.invoke(new ObjectFactory().createAddNumbers(input));
int result = o.getValue().getReturn();
assert (result == 6);
}
use of com.sun.xml.ws.developer.MemberSubmissionEndpointReference in project metro-jax-ws by eclipse-ee4j.
the class AddNumbersClient method testDispatchWithEPRAddress.
/**
* In this testcase, the Service instance is created with a
* fake wsdl (incorrect endpoint adress). Normal invocation would have failed.
* But the Dispatch is created with EPR which has valid endpoint address.
* So, epr address shoudl take precedence and invocation should succeed.
*/
public void testDispatchWithEPRAddress() throws Exception {
if (ClientServerTestUtil.useLocal()) {
System.out.println("HTTP Transport Only Exiting");
return;
}
// W3CEndpointReferenceBuilder eprBuilder = new W3CEndpointReferenceBuilder();
// eprBuilder.address(ENDPOINT_ADDRESS);
// eprBuilder.serviceName(SERVICE_QNAME);
// eprBuilder.endpointName(PORT_QNAME);
// W3CEndpointReference epr = eprBuilder.build();
WSEndpointReference wsepr = new WSEndpointReference(AddressingVersion.MEMBER, ENDPOINT_ADDRESS, SERVICE_QNAME, PORT_QNAME, null, null, null, null);
MemberSubmissionEndpointReference epr = wsepr.toSpec(MemberSubmissionEndpointReference.class);
URL fakeWsdlUrl = Thread.currentThread().getContextClassLoader().getResource("wsdl/AddNumbersFake.wsdl");
Service service = Service.create(fakeWsdlUrl, SERVICE_QNAME);
JAXBContext jc = createJAXBContext();
Dispatch<Object> dispatch = service.createDispatch(epr, jc, Service.Mode.PAYLOAD, new AddressingFeature());
AddNumbers input = new AddNumbers();
input.setNumber1(2);
input.setNumber2(4);
JAXBElement<AddNumbersResponse> o = (JAXBElement<AddNumbersResponse>) dispatch.invoke(new ObjectFactory().createAddNumbers(input));
int result = o.getValue().getReturn();
assert (result == 6);
}
use of com.sun.xml.ws.developer.MemberSubmissionEndpointReference in project metro-jax-ws by eclipse-ee4j.
the class AddNumbersClient method testCreateDispatchJAXBMSEPRNoPortQName.
// UsingAddressing wsdl:required=true
// RespectBindingFeature Disabled - no effect - behavior undefined by specification
// for backward compatability
public void testCreateDispatchJAXBMSEPRNoPortQName() throws Exception {
if (ClientServerTestUtil.useLocal()) {
System.out.println("HTTP Transport Only Exiting");
return;
}
RespectBindingFeature rbf = new RespectBindingFeature(true);
WebServiceFeature[] wse = new WebServiceFeature[] { rbf };
Service service = createServiceWithWSDL();
MemberSubmissionEndpointReference msEPR = createMSEPRStubServiceWithWSDL(service);
msEPR.portTypeName.name = null;
MSEPRString = msEPR.toString();
Dispatch<Object> dispatch = service.createDispatch(EndpointReference.readFrom(makeStreamSource(MSEPRString)), createJAXBContext(), Service.Mode.PAYLOAD, wse);
AddNumbers addNumbers = factory.createAddNumbers();
addNumbers.setNumber1(2);
addNumbers.setNumber2(4);
JAXBElement<AddNumbers> num = factory.createAddNumbers(addNumbers);
JAXBElement<AddNumbersResponse> addNumbersResponse = (JAXBElement<AddNumbersResponse>) dispatch.invoke(num);
AddNumbersResponse response = addNumbersResponse.getValue();
assertEquals(response.getReturn(), 2 + 4);
}
use of com.sun.xml.ws.developer.MemberSubmissionEndpointReference in project metro-jax-ws by eclipse-ee4j.
the class AddNumbersClient method testCreateDispatchSourceMSEPRNoPortQName.
// UsingAddressing wsdl:required=true
public void testCreateDispatchSourceMSEPRNoPortQName() throws Exception {
if (ClientServerTestUtil.useLocal()) {
System.out.println("HTTP Transport Only Exiting");
return;
}
RespectBindingFeature rbf = new RespectBindingFeature(true);
WebServiceFeature[] wse = new WebServiceFeature[] { rbf };
Service service = createServiceWithWSDL();
MemberSubmissionEndpointReference msEPR = createMSEPRStubServiceWithWSDL(service);
// MemberSubmissionEndpointReference.AttributedQName portTypeName = msEPR.portTypeName;
// QName portQName = portTypeName.name;
msEPR.portTypeName.name = null;
MSEPRString = msEPR.toString();
Dispatch<Source> dispatch = service.createDispatch(EndpointReference.readFrom(makeStreamSource(MSEPRString)), Source.class, Service.Mode.PAYLOAD, wse);
Source result = dispatch.invoke(makeStreamSource(MSGSrc));
JAXBElement<AddNumbersResponse> addNumberResponse = (JAXBElement<AddNumbersResponse>) createJAXBContext().createUnmarshaller().unmarshal(result);
AddNumbersResponse response = addNumberResponse.getValue();
assertEquals(response.getReturn(), 2 + 4);
}
Aggregations