use of jakarta.xml.ws.soap.AddressingFeature in project metro-jax-ws by eclipse-ee4j.
the class AddressingPolicyMapConfigurator method update.
/**
* Puts an addressing policy into the PolicyMap if the addressing feature was set.
*/
public Collection<PolicySubject> update(final PolicyMap policyMap, final SEIModel model, final WSBinding wsBinding) throws PolicyException {
LOGGER.entering(policyMap, model, wsBinding);
Collection<PolicySubject> subjects = new ArrayList<>();
if (policyMap != null) {
final AddressingFeature addressingFeature = wsBinding.getFeature(AddressingFeature.class);
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.finest("addressingFeature = " + addressingFeature);
}
if ((addressingFeature != null) && addressingFeature.isEnabled()) {
// add wsam:Addrressing assertion if not exists.
addWsamAddressing(subjects, policyMap, model, addressingFeature);
}
}
// endif policy map not null
LOGGER.exiting(subjects);
return subjects;
}
use of jakarta.xml.ws.soap.AddressingFeature in project metro-jax-ws by eclipse-ee4j.
the class AddressingPolicyMapConfigurator method createWsamAddressingPolicy.
/**
* Create a policy with an WSAM Addressing assertion.
*/
private Policy createWsamAddressingPolicy(final QName bindingName, AddressingFeature af) {
final ArrayList<AssertionSet> assertionSets = new ArrayList<>(1);
final ArrayList<PolicyAssertion> assertions = new ArrayList<>(1);
final AssertionData addressingData = AssertionData.createAssertionData(W3CAddressingMetadataConstants.WSAM_ADDRESSING_ASSERTION);
if (!af.isRequired()) {
addressingData.setOptionalAttribute(true);
}
try {
AddressingFeature.Responses responses = af.getResponses();
if (responses == AddressingFeature.Responses.ANONYMOUS) {
AssertionData nestedAsserData = AssertionData.createAssertionData(W3CAddressingMetadataConstants.WSAM_ANONYMOUS_NESTED_ASSERTION);
PolicyAssertion nestedAsser = new AddressingAssertion(nestedAsserData, null);
assertions.add(new AddressingAssertion(addressingData, AssertionSet.createAssertionSet(Collections.singleton(nestedAsser))));
} else if (responses == AddressingFeature.Responses.NON_ANONYMOUS) {
final AssertionData nestedAsserData = AssertionData.createAssertionData(W3CAddressingMetadataConstants.WSAM_NONANONYMOUS_NESTED_ASSERTION);
PolicyAssertion nestedAsser = new AddressingAssertion(nestedAsserData, null);
assertions.add(new AddressingAssertion(addressingData, AssertionSet.createAssertionSet(Collections.singleton(nestedAsser))));
} else {
assertions.add(new AddressingAssertion(addressingData, AssertionSet.createAssertionSet(null)));
}
} catch (NoSuchMethodError e) {
// If JAX-WS 2.2 API is really required, it would been reported in @Addressing or wsam:Addressing processing
// Don't add any nested assertion to mimic the 2.1 behavior
assertions.add(new AddressingAssertion(addressingData, AssertionSet.createAssertionSet(null)));
}
assertionSets.add(AssertionSet.createAssertionSet(assertions));
return Policy.createPolicy(null, bindingName.getLocalPart() + "_WSAM_Addressing_Policy", assertionSets);
}
use of jakarta.xml.ws.soap.AddressingFeature in project metro-jax-ws by eclipse-ee4j.
the class AddNumbersClient method createDispatchWithoutWSDL.
private Dispatch<SOAPMessage> createDispatchWithoutWSDL() throws Exception {
Service service = Service.create(SERVICE_QNAME);
service.addPort(PORT_QNAME, SOAPBinding.SOAP11HTTP_BINDING, getAddress());
Dispatch<SOAPMessage> dispatch = service.createDispatch(PORT_QNAME, SOAPMessage.class, Service.Mode.MESSAGE, new AddressingFeature(false, false));
return dispatch;
}
use of jakarta.xml.ws.soap.AddressingFeature in project metro-jax-ws by eclipse-ee4j.
the class AddNumbersClient method createDispatchWithoutWSDL.
private Dispatch<SOAPMessage> createDispatchWithoutWSDL() throws Exception {
AddNumbersService service = new AddNumbersService();
Dispatch<SOAPMessage> dispatch = service.createDispatch(PORT_QNAME, SOAPMessage.class, Service.Mode.MESSAGE, new AddressingFeature(false, false));
return dispatch;
}
use of jakarta.xml.ws.soap.AddressingFeature in project metro-jax-ws by eclipse-ee4j.
the class AddNumbersClient method testAddressingWithNoWSDLwithHandler.
public void testAddressingWithNoWSDLwithHandler() throws Exception {
Service service = Service.create(SERVICE_QNAME);
service.addPort(PORT_QNAME, SOAPBinding.SOAP11HTTP_BINDING, getAddress());
Dispatch<SOAPMessage> dispatch = service.createDispatch(PORT_QNAME, SOAPMessage.class, Service.Mode.MESSAGE, new AddressingFeature());
dispatch.getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, true);
dispatch.getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, ADD_NUMBERS_ACTION);
String message = "<S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\"><S:Body>" + "<addNumbers xmlns=\"http://example.com/\">" + "<number1>10</number1>" + "<number2>10</number2>" + "</addNumbers>" + "</S:Body></S:Envelope>";
List<Handler> handlerChain = dispatch.getBinding().getHandlerChain();
handlerChain.add(new MyHandler());
dispatch.getBinding().setHandlerChain(handlerChain);
WsaUtils.invoke(dispatch, message);
}
Aggregations