use of jakarta.xml.ws.soap.AddressingFeature in project metro-jax-ws by eclipse-ee4j.
the class AddNumbersClient method testEPRGetPortV.
// UsingAddressing wsdl:required=true
// AddressingFeature Disabled expect Exception
// Expect no valid addressingport created, so exception thrown
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 testEPRGetPortVIIII.
// UsingAddressing wsdl:required=true
// AddressingFeature Disabled expect Exception
// Expect no valid port created, so exception thrown
public void testEPRGetPortVIIII() 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, 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 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 jakarta.xml.ws.soap.AddressingFeature in project metro-jax-ws by eclipse-ee4j.
the class AddNumbersClient method testEPRGetPortIV.
// UsingAddressing wsdl:required=true
// AddressingFeature Disabled expect Exception
// Expect no valid port created, so exception thrown
public void testEPRGetPortIV() throws Exception {
if (ClientServerTestUtil.useLocal()) {
System.out.println("HTTP Transport Only Exiting");
return;
}
AddNumbersPortType proxy = createStub();
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 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());
}
}
Aggregations