use of jakarta.xml.ws.soap.AddressingFeature in project metro-jax-ws by eclipse-ee4j.
the class WSServiceDelegate method createDispatch.
public <T> Dispatch<T> createDispatch(QName portName, Class<T> aClass, Service.Mode mode, WebServiceFeatureList features) {
WSEndpointReference wsepr = null;
boolean isAddressingEnabled = false;
AddressingFeature af = features.get(AddressingFeature.class);
if (af == null) {
af = this.features.get(AddressingFeature.class);
}
if (af != null && af.isEnabled())
isAddressingEnabled = true;
MemberSubmissionAddressingFeature msa = features.get(MemberSubmissionAddressingFeature.class);
if (msa == null) {
msa = this.features.get(MemberSubmissionAddressingFeature.class);
}
if (msa != null && msa.isEnabled())
isAddressingEnabled = true;
if (isAddressingEnabled && wsdlService != null && wsdlService.get(portName) != null) {
wsepr = wsdlService.get(portName).getEPR();
}
return createDispatch(portName, wsepr, aClass, mode, features);
}
use of jakarta.xml.ws.soap.AddressingFeature in project metro-jax-ws by eclipse-ee4j.
the class WebServiceFeatureList method getFeature.
/**
* Returns a corresponding feature for a feature annotation(i.e which has
* {@link WebServiceFeatureAnnotation} meta annotation)
*
* @return corresponding feature for the annotation
* null, if the annotation is nota feature annotation
*/
public static WebServiceFeature getFeature(Annotation a) {
WebServiceFeature ftr = null;
if (!(a.annotationType().isAnnotationPresent(WebServiceFeatureAnnotation.class))) {
ftr = null;
} else if (a instanceof Addressing) {
Addressing addAnn = (Addressing) a;
try {
ftr = new AddressingFeature(addAnn.enabled(), addAnn.required(), addAnn.responses());
} catch (NoSuchMethodError e) {
// throw error. We can't default to Responses.ALL as we dont know if the user has not used 2.2 annotation with responses.
throw new RuntimeModelerException(ModelerMessages.RUNTIME_MODELER_ADDRESSING_RESPONSES_NOSUCHMETHOD(toJar(Which.which(Addressing.class))));
}
} else if (a instanceof MTOM) {
MTOM mtomAnn = (MTOM) a;
ftr = new MTOMFeature(mtomAnn.enabled(), mtomAnn.threshold());
} else if (a instanceof RespectBinding) {
RespectBinding rbAnn = (RespectBinding) a;
ftr = new RespectBindingFeature(rbAnn.enabled());
} else {
ftr = getWebServiceFeatureBean(a);
}
return ftr;
}
use of jakarta.xml.ws.soap.AddressingFeature in project metro-jax-ws by eclipse-ee4j.
the class AddNumbersClient method testEPRGetPortVIIII.
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 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);
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 AddressingFeatureConfigurator method getFeatures.
public Collection<WebServiceFeature> getFeatures(final PolicyMapKey key, final PolicyMap policyMap) throws PolicyException {
LOGGER.entering(key, policyMap);
final Collection<WebServiceFeature> features = new LinkedList<>();
if ((key != null) && (policyMap != null)) {
final Policy policy = policyMap.getEndpointEffectivePolicy(key);
for (QName addressingAssertionQName : ADDRESSING_ASSERTIONS) {
if ((policy != null) && policy.contains(addressingAssertionQName)) {
final Iterator<AssertionSet> assertions = policy.iterator();
while (assertions.hasNext()) {
final AssertionSet assertionSet = assertions.next();
final Iterator<PolicyAssertion> policyAssertion = assertionSet.iterator();
while (policyAssertion.hasNext()) {
final PolicyAssertion assertion = policyAssertion.next();
if (assertion.getName().equals(addressingAssertionQName)) {
final WebServiceFeature feature = AddressingVersion.getFeature(addressingAssertionQName.getNamespaceURI(), true, !assertion.isOptional());
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.fine("Added addressing feature \"" + feature + "\" for element \"" + key + "\"");
}
features.add(feature);
}
// end-if non optional wsa assertion found
}
// next assertion
}
// next alternative
}
// end-if policy contains wsa assertion
}
// Deal with WS-Addressing 1.0 Metadata assertions
if (policy != null && policy.contains(W3CAddressingMetadataConstants.WSAM_ADDRESSING_ASSERTION)) {
for (AssertionSet assertions : policy) {
for (PolicyAssertion assertion : assertions) {
if (assertion.getName().equals(W3CAddressingMetadataConstants.WSAM_ADDRESSING_ASSERTION)) {
NestedPolicy nestedPolicy = assertion.getNestedPolicy();
boolean requiresAnonymousResponses = false;
boolean requiresNonAnonymousResponses = false;
if (nestedPolicy != null) {
requiresAnonymousResponses = nestedPolicy.contains(W3CAddressingMetadataConstants.WSAM_ANONYMOUS_NESTED_ASSERTION);
requiresNonAnonymousResponses = nestedPolicy.contains(W3CAddressingMetadataConstants.WSAM_NONANONYMOUS_NESTED_ASSERTION);
}
if (requiresAnonymousResponses && requiresNonAnonymousResponses) {
throw new WebServiceException("Only one among AnonymousResponses and NonAnonymousResponses can be nested in an Addressing assertion");
}
final WebServiceFeature feature;
try {
if (requiresAnonymousResponses) {
feature = new AddressingFeature(true, !assertion.isOptional(), AddressingFeature.Responses.ANONYMOUS);
} else if (requiresNonAnonymousResponses) {
feature = new AddressingFeature(true, !assertion.isOptional(), AddressingFeature.Responses.NON_ANONYMOUS);
} else {
feature = new AddressingFeature(true, !assertion.isOptional());
}
} catch (NoSuchMethodError e) {
throw LOGGER.logSevereException(new PolicyException(ModelerMessages.RUNTIME_MODELER_ADDRESSING_RESPONSES_NOSUCHMETHOD(toJar(Which.which(AddressingFeature.class))), e));
}
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.fine("Added addressing feature \"" + feature + "\" for element \"" + key + "\"");
}
features.add(feature);
}
}
}
}
}
LOGGER.exiting(features);
return features;
}
Aggregations