use of com.sun.xml.ws.developer.MemberSubmissionAddressingFeature in project metro-jax-ws by eclipse-ee4j.
the class AddNumbersClient method testCustomFault.
/**
* This test tests the functionality of OnewayFeature and AddressingFeature the way it being used in WS-AT implementation
* In WS-AT impl, Server-side has to send fault messages to predefined coordinator and this test replicates that usage.
*
* @throws Exception
*/
public void testCustomFault() throws Exception {
if (ClientServerTestUtil.useLocal()) {
System.out.println("Only Testable in HTTP transport!");
return;
}
SOAPFault fault = SOAPFactory.newInstance().createFault("custom fault from client", SOAPConstants.SOAP_SENDER_FAULT);
InputStream is = getClass().getClassLoader().getResourceAsStream("wsa/fromwsdl/custom/config/AddNumbers.wsdl");
assertNotNull("WSDL cannot be read", is);
ArrayList<Element> metadata = new ArrayList<Element>();
metadata.add((Element) DOMUtil.createDOMNode(is).getFirstChild());
// WSEndpointReference to = new WSEndpointReference(AddressingVersion.W3C,
// getAddress(),
// SERVICE_QNAME,
// PORT_QNAME,
// PORT_TYPE_QNAME,
// metadata,
// getWsdlAddress(),
// null);
OneWayFeature owf = new OneWayFeature();
owf.setRelatesToID("uuid:foobar");
Service service = Service.create(SERVICE_QNAME);
service.addPort(PORT_QNAME, SOAPBinding.SOAP11HTTP_BINDING, getAddress());
// Dispatch<Source> dispatch = service.createDispatch(to.toSpec(), Source.class,
// Service.Mode.PAYLOAD,
// new AddressingFeature(true, true),
// owf);
Dispatch<Source> dispatch = service.createDispatch(PORT_QNAME, Source.class, Service.Mode.PAYLOAD, new MemberSubmissionAddressingFeature(true), owf);
// Since this fault is not a wsdl operation, we need to set SOAPAction for correct wsa:Action
dispatch.getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, true);
dispatch.getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, "http://example.com/myfault");
try {
dispatch.invokeOneWay(new DOMSource(fault));
} catch (WebServiceException e) {
// since the server-side is not provider based for this test.
// it does n't know from the fault message request that it is oneway and throws 500 code.
// so, expect a WebServcieException here.
}
// System.out.println(dispatch.getRequestContext().get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY));
}
use of com.sun.xml.ws.developer.MemberSubmissionAddressingFeature in project metro-jax-ws by eclipse-ee4j.
the class AddNumbersClient method createDispatchWithWSDL.
private Dispatch<SOAPMessage> createDispatchWithWSDL() throws Exception {
MemberSubmissionAddressingFeature msAddressingFeature = new MemberSubmissionAddressingFeature(true);
RespectBindingFeature respectBindingFeature = new RespectBindingFeature(true);
WebServiceFeature[] features = new WebServiceFeature[] { msAddressingFeature, respectBindingFeature };
AddNumbersService service = new AddNumbersService();
return service.createDispatch(PORT_QNAME, SOAPMessage.class, Service.Mode.MESSAGE);
}
use of com.sun.xml.ws.developer.MemberSubmissionAddressingFeature in project metro-jax-ws by eclipse-ee4j.
the class AddNumbersClient method testReplyToRefpsWithWSDL.
public void testReplyToRefpsWithWSDL() throws Exception {
MemberSubmissionAddressingFeature addressingFeature = new MemberSubmissionAddressingFeature(false);
WebServiceFeature[] features = new WebServiceFeature[] { addressingFeature };
Dispatch dispatch = createDispatchWithWSDL(features);
BindingImpl binding = (BindingImpl) dispatch.getBinding();
boolean enabled = AddressingVersion.isEnabled(binding);
assertTrue(enabled);
SOAPMessage response = WsaUtils.invoke(dispatch, WsaUtils.REPLY_TO_REFPS_MESSAGE, WsaUtils.S11_NS, WsaUtils.W3C_WSA_NS, getAddress(), W3CAddressingConstants.WSA_ANONYMOUS_ADDRESS, CORRECT_ACTION);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
response.writeTo(baos);
assertXpathExists(REPLY_TO_REFPS, baos.toString());
assertXpathEvaluatesTo(REPLY_TO_REFPS_VALUE, baos.toString(), "Key#123456789");
assertXpathExists(REPLY_TO_REFPS_ISREFP, baos.toString());
}
use of com.sun.xml.ws.developer.MemberSubmissionAddressingFeature in project metro-jax-ws by eclipse-ee4j.
the class AddNumbersClient method testEPRGetPortVIIIII.
// UsingAddressing wsdl:required=true
// AddressingFeature Disabled expect Exception
// Expect no valid port created, so exception thrown
public void testEPRGetPortVIIIII() throws Exception {
if (ClientServerTestUtil.useLocal()) {
System.out.println("HTTP Transport Only Exiting");
return;
}
AddNumbersPortType proxy = createStub();
EndpointReference epr = ((BindingProvider) proxy).getEndpointReference(MemberSubmissionEndpointReference.class);
RespectBindingFeature feature = new RespectBindingFeature(true);
MemberSubmissionAddressingFeature addr = new MemberSubmissionAddressingFeature(true, true);
WebServiceFeature[] features = new WebServiceFeature[] { feature, addr };
AddNumbersPortType port = epr.getPort(AddNumbersPortType.class, features);
assertTrue(port != null);
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 com.sun.xml.ws.developer.MemberSubmissionAddressingFeature in project metro-jax-ws by eclipse-ee4j.
the class MemberSubmissionAddressingWSDLParserExtension method addressibleElement.
private boolean addressibleElement(XMLStreamReader reader, WSDLFeaturedObject binding) {
QName ua = reader.getName();
if (ua.equals(AddressingVersion.MEMBER.wsdlExtensionTag)) {
String required = reader.getAttributeValue(WSDLConstants.NS_WSDL, "required");
binding.addFeature(new MemberSubmissionAddressingFeature(Boolean.parseBoolean(required)));
XMLStreamReaderUtil.skipElement(reader);
// UsingAddressing is consumed
return true;
}
return false;
}
Aggregations