use of jakarta.xml.ws.soap.AddressingFeature 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 jakarta.xml.ws.soap.AddressingFeature in project metro-jax-ws by eclipse-ee4j.
the class AddNumbersClient method testEPRGetPortVIIIIII.
// UsingAddressing wsdl:required=true
// AddressingFeature Disabled expect Exception
// Expect no valid port created, so exception thrown
public void testEPRGetPortVIIIIII() throws Exception {
if (ClientServerTestUtil.useLocal()) {
System.out.println("HTTP Transport Only Exiting");
return;
}
AddNumbersPortType proxy = createStub();
// EndpointReference epr = ((BindingProvider) proxy).getEndpointReference(W3CEndpointReference.class);
EndpointReference epr = ((BindingProvider) proxy).getEndpointReference(MemberSubmissionEndpointReference.class);
RespectBindingFeature feature = new RespectBindingFeature(true);
AddressingFeature addr = new AddressingFeature(true, true);
WebServiceFeature[] features = new WebServiceFeature[] { feature, addr };
AddNumbersPortType port = epr.getPort(AddNumbersPortType.class, features);
assertTrue(port != null);
// expectation is that port is not configured for addressing and the invocation will fail
System.out.println("Adding numbers 2 and 4");
int result = port.addNumbers(2, 4);
assert (result == 6);
System.out.println("Addinion of 2 and 4 successful");
}
use of jakarta.xml.ws.soap.AddressingFeature in project metro-jax-ws by eclipse-ee4j.
the class AddNumbersClient method testEPRGetPortVII.
// UsingAddressing wsdl:required=true
// AddressingFeature Disabled expect Exception
// Expect no valid port created, so exception thrown
public void testEPRGetPortVII() throws Exception {
if (ClientServerTestUtil.useLocal()) {
System.out.println("HTTP Transport Only Exiting");
return;
}
AddNumbersPortType proxy = createStub();
// EndpointReference epr = ((BindingProvider) proxy).getEndpointReference(W3CEndpointReference.class);
EndpointReference epr = ((BindingProvider) proxy).getEndpointReference(MemberSubmissionEndpointReference.class);
RespectBindingFeature feature = new RespectBindingFeature(true);
AddressingFeature addr = new AddressingFeature(false, false);
WebServiceFeature[] features = new WebServiceFeature[] { feature, addr };
AddNumbersPortType port = epr.getPort(AddNumbersPortType.class, features);
assertTrue(port != null);
// expectation is that port is not configured for addressing and the invocation will fail
try {
System.out.println("Adding numbers 2 and 4");
int result = port.addNumbers(2, 4);
} catch (Exception ex) {
assertTrue(ex instanceof SOAPFaultException);
System.out.println(((SOAPFaultException) ex).getFault().getFaultString());
}
}
use of jakarta.xml.ws.soap.AddressingFeature in project metro-jax-ws by eclipse-ee4j.
the class AddNumbersClient method testEPRGetPortV.
public void testEPRGetPortV() throws Exception {
if (ClientServerTestUtil.useLocal()) {
System.out.println("HTTP Transport Only Exiting");
return;
}
AddNumbersPortType proxy = createStub();
// EndpointReference epr = ((BindingProvider) proxy).getEndpointReference(W3CEndpointReference.class);
EndpointReference epr = ((BindingProvider) proxy).getEndpointReference(MemberSubmissionEndpointReference.class);
// force addressing off
AddressingFeature feature = new AddressingFeature(false, false);
WebServiceFeature[] features = new WebServiceFeature[] { feature };
AddNumbersPortType port = epr.getPort(AddNumbersPortType.class, features);
assertTrue(port != null);
// expectation is that port is not configured for addressing and the invocation will fail
try {
System.out.println("Adding numbers 2 and 4");
int result = port.addNumbers(2, 4);
} catch (Exception ex) {
assertTrue(ex instanceof SOAPFaultException);
System.out.println(((SOAPFaultException) ex).getFault().getFaultString());
}
}
use of jakarta.xml.ws.soap.AddressingFeature in project metro-jax-ws by eclipse-ee4j.
the class AddNumbersClient method testEPRGetPortVIIIIII.
public void testEPRGetPortVIIIIII() throws Exception {
if (ClientServerTestUtil.useLocal()) {
System.out.println("HTTP Transport Only Exiting");
return;
}
AddNumbersPortType proxy = createStub();
// EndpointReference epr = ((BindingProvider) proxy).getEndpointReference(W3CEndpointReference.class);
EndpointReference epr = ((BindingProvider) proxy).getEndpointReference(MemberSubmissionEndpointReference.class);
RespectBindingFeature feature = new RespectBindingFeature(true);
AddressingFeature addr = new AddressingFeature(true, true);
WebServiceFeature[] features = new WebServiceFeature[] { feature, addr };
AddNumbersPortType port = epr.getPort(AddNumbersPortType.class, features);
assertTrue(port != null);
// expectation is that port is not configured for addressing and the invocation will fail
System.out.println("Adding numbers 2 and 4");
int result = port.addNumbers(2, 4);
assert (result == 6);
System.out.println("Addinion of 2 and 4 successful");
}
Aggregations