use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.
the class WsaTubeHelper method getFaultActionFromSEIModel.
String getFaultActionFromSEIModel(Packet requestPacket, Packet responsePacket) {
String action = null;
if (seiModel == null || wsdlPort == null) {
return action;
}
try {
SOAPMessage sm = responsePacket.getMessage().copy().readAsSOAPMessage();
if (sm == null) {
return action;
}
if (sm.getSOAPBody() == null) {
return action;
}
if (sm.getSOAPBody().getFault() == null) {
return action;
}
Detail detail = sm.getSOAPBody().getFault().getDetail();
if (detail == null) {
return action;
}
String ns = detail.getFirstChild().getNamespaceURI();
String name = detail.getFirstChild().getLocalName();
WSDLOperationMapping wsdlOp = requestPacket.getWSDLOperationMapping();
JavaMethodImpl jm = (wsdlOp != null) ? (JavaMethodImpl) wsdlOp.getJavaMethod() : null;
if (jm != null) {
for (CheckedExceptionImpl ce : jm.getCheckedExceptions()) {
if (ce.getDetailType().tagName.getLocalPart().equals(name) && ce.getDetailType().tagName.getNamespaceURI().equals(ns)) {
return ce.getFaultAction();
}
}
}
return action;
} catch (SOAPException e) {
throw new WebServiceException(e);
}
}
use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.
the class WsaTubeHelper method createInvalidAddressingHeaderFault.
public SOAPFault createInvalidAddressingHeaderFault(InvalidAddressingHeaderException e, AddressingVersion av) {
QName name = e.getProblemHeader();
QName subsubcode = e.getSubsubcode();
QName subcode = av.invalidMapTag;
String faultstring = String.format(av.getInvalidMapText(), name, subsubcode);
try {
SOAPFactory factory;
SOAPFault fault;
if (soapVer == SOAPVersion.SOAP_12) {
factory = SOAPVersion.SOAP_12.getSOAPFactory();
fault = factory.createFault();
fault.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT);
fault.appendFaultSubcode(subcode);
fault.appendFaultSubcode(subsubcode);
getInvalidMapDetail(name, fault.addDetail());
} else {
factory = SOAPVersion.SOAP_11.getSOAPFactory();
fault = factory.createFault();
fault.setFaultCode(subsubcode);
}
fault.setFaultString(faultstring);
return fault;
} catch (SOAPException se) {
throw new WebServiceException(se);
}
}
use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.
the class WsaTubeHelper method newMapRequiredFault.
public SOAPFault newMapRequiredFault(MissingAddressingHeaderException e) {
QName subcode = addVer.mapRequiredTag;
QName subsubcode = addVer.mapRequiredTag;
String faultstring = addVer.getMapRequiredText();
try {
SOAPFactory factory;
SOAPFault fault;
if (soapVer == SOAPVersion.SOAP_12) {
factory = SOAPVersion.SOAP_12.getSOAPFactory();
fault = factory.createFault();
fault.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT);
fault.appendFaultSubcode(subcode);
fault.appendFaultSubcode(subsubcode);
getMapRequiredDetail(e.getMissingHeaderQName(), fault.addDetail());
} else {
factory = SOAPVersion.SOAP_11.getSOAPFactory();
fault = factory.createFault();
fault.setFaultCode(subsubcode);
}
fault.setFaultString(faultstring);
return fault;
} catch (SOAPException se) {
throw new WebServiceException(se);
}
}
use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.
the class WsaTubeHelper method getFaultAction.
String getFaultAction(@Nullable WSDLBoundOperation wbo, Packet responsePacket) {
String action = AddressingUtils.getAction(responsePacket.getMessage().getHeaders(), addVer, soapVer);
if (action != null) {
return action;
}
action = addVer.getDefaultFaultAction();
if (wbo == null) {
return action;
}
try {
SOAPMessage sm = responsePacket.getMessage().copy().readAsSOAPMessage();
if (sm == null) {
return action;
}
if (sm.getSOAPBody() == null) {
return action;
}
if (sm.getSOAPBody().getFault() == null) {
return action;
}
Detail detail = sm.getSOAPBody().getFault().getDetail();
if (detail == null) {
return action;
}
String ns = detail.getFirstChild().getNamespaceURI();
String name = detail.getFirstChild().getLocalName();
WSDLOperation o = wbo.getOperation();
WSDLFault fault = o.getFault(new QName(ns, name));
if (fault == null) {
return action;
}
action = fault.getAction();
return action;
} catch (SOAPException e) {
throw new WebServiceException(e);
}
}
use of jakarta.xml.ws.WebServiceException 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