use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.
the class WsaClientTube method validateAction.
@Override
protected void validateAction(Packet packet) {
// There may not be a WSDL operation. There may not even be a WSDL.
// For instance this may be a RM CreateSequence message.
WSDLBoundOperation wbo = getWSDLBoundOperation(packet);
if (wbo == null)
return;
String gotA = AddressingUtils.getAction(packet.getMessage().getHeaders(), addressingVersion, soapVersion);
if (gotA == null)
throw new WebServiceException(AddressingMessages.VALIDATION_CLIENT_NULL_ACTION());
String expected = helper.getOutputAction(packet);
if (expected != null && !gotA.equals(expected))
throw new ActionNotSupportedException(gotA);
}
use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.
the class WsaServerTube method processResponse.
@Override
@NotNull
public NextAction processResponse(Packet response) {
Message msg = response.getMessage();
if (msg == null) {
return doReturnWith(response);
}
// one way message. Nothing to see here. Move on.
String to = AddressingUtils.getTo(msg.getHeaders(), addressingVersion, soapVersion);
if (to != null) {
replyTo = faultTo = new WSEndpointReference(to, addressingVersion);
}
if (replyTo == null) {
// This is an async response or we're not processing the response in
// the same tube instance as we processed the request. Get the ReplyTo
// now, from the properties we stored into the request packet. We
// assume anyone that interrupted the request->response flow will have
// saved the ReplyTo and put it back into the packet for our use.
replyTo = (WSEndpointReference) response.get(WsaPropertyBag.WSA_REPLYTO_FROM_REQUEST);
}
if (faultTo == null) {
// This is an async response or we're not processing the response in
// the same tube instance as we processed the request. Get the FaultTo
// now, from the properties we stored into the request packet. We
// assume anyone that interrupted the request->response flow will have
// saved the FaultTo and put it back into the packet for our use.
faultTo = (WSEndpointReference) response.get(WsaPropertyBag.WSA_FAULTTO_FROM_REQUEST);
}
WSEndpointReference target = msg.isFault() ? faultTo : replyTo;
if (target == null && response.proxy instanceof Stub) {
target = ((Stub) response.proxy).getWSEndpointReference();
}
if (target == null || target.isAnonymous() || isAnonymousRequired) {
return doReturnWith(response);
}
if (target.isNone()) {
// the caller doesn't want to hear about it, so proceed like one-way
response.setMessage(null);
return doReturnWith(response);
}
if ((wsdlPort != null) && response.getMessage().isOneWay(wsdlPort)) {
// one way message but with replyTo. I believe this is a hack for WS-TX - KK.
LOGGER.fine(AddressingMessages.NON_ANONYMOUS_RESPONSE_ONEWAY());
return doReturnWith(response);
}
// action value.
if (wbo != null || response.soapAction == null) {
String action = response.getMessage().isFault() ? helper.getFaultAction(wbo, response) : helper.getOutputAction(wbo);
// set the SOAPAction, as its got to be same as wsa:Action
if (response.soapAction == null || (action != null && !action.equals(AddressingVersion.UNSET_OUTPUT_ACTION))) {
response.soapAction = action;
}
}
response.expectReply = false;
EndpointAddress adrs;
try {
adrs = new EndpointAddress(URI.create(target.getAddress()));
} catch (NullPointerException | IllegalArgumentException e) {
throw new WebServiceException(e);
}
response.endpointAddress = adrs;
if (response.isAdapterDeliversNonAnonymousResponse) {
return doReturnWith(response);
}
return doReturnWith(NonAnonymousResponseProcessor.getDefault().process(response));
}
use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.
the class WSEndpointReference method parseEPRExtensions.
private void parseEPRExtensions() throws XMLStreamException {
rootEprExtensions = new HashMap<>();
StreamReaderBufferProcessor xsr = infoset.readAsXMLStreamReader();
// parser should be either at the start element or the start document
if (xsr.getEventType() == XMLStreamReader.START_DOCUMENT) {
xsr.nextTag();
}
assert xsr.getEventType() == XMLStreamReader.START_ELEMENT;
if (!xsr.getNamespaceURI().equals(version.nsUri)) {
throw new WebServiceException(AddressingMessages.WRONG_ADDRESSING_VERSION(version.nsUri, xsr.getNamespaceURI()));
}
// since often EPR doesn't have extensions, create array lazily
XMLStreamBuffer mark;
String localName;
String ns;
while ((mark = xsr.nextTagAndMark()) != null) {
localName = xsr.getLocalName();
ns = xsr.getNamespaceURI();
if (version.nsUri.equals(ns)) {
// EPR extensions do not use the same namespace of the Addressing Version.
// Not an extension - SKIP
XMLStreamReaderUtil.skipElement(xsr);
} else {
QName qn = new QName(ns, localName);
rootEprExtensions.put(qn, new WSEPRExtension(mark, qn));
XMLStreamReaderUtil.skipElement(xsr);
}
}
// hit to </EndpointReference> by now
}
use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.
the class WSEndpointReference method createBufferFromData.
private static XMLStreamBuffer createBufferFromData(AddressingVersion version, String address, List<Element> referenceParameters, QName service, QName port, QName portType, List<Element> metadata, String wsdlAddress, String wsdlTargetNamespace, @Nullable List<Element> elements, @Nullable Map<QName, String> attributes) {
StreamWriterBufferCreator writer = new StreamWriterBufferCreator();
try {
writer.writeStartDocument();
writer.writeStartElement(version.getPrefix(), "EndpointReference", version.nsUri);
writer.writeNamespace(version.getPrefix(), version.nsUri);
writePartialEPRInfoset(writer, version, address, referenceParameters, service, port, portType, metadata, wsdlAddress, wsdlTargetNamespace, attributes);
// write extensibility elements in the EPR element
if (elements != null) {
for (Element e : elements) {
DOMUtil.serializeNode(e, writer);
}
}
writer.writeEndElement();
writer.writeEndDocument();
writer.flush();
return writer.getXMLStreamBuffer();
} catch (XMLStreamException e) {
throw new WebServiceException(e);
}
}
use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.
the class WSEndpointReference method createBufferFromData.
private static XMLStreamBuffer createBufferFromData(AddressingVersion version, String address, List<Element> referenceParameters, QName service, QName port, QName portType, List<Element> metadata, String wsdlAddress, String wsdlTargetNamespace, @Nullable Collection<EPRExtension> extns, @Nullable Map<QName, String> attributes) {
StreamWriterBufferCreator writer = new StreamWriterBufferCreator();
try {
writer.writeStartDocument();
writer.writeStartElement(version.getPrefix(), "EndpointReference", version.nsUri);
writer.writeNamespace(version.getPrefix(), version.nsUri);
writePartialEPRInfoset(writer, version, address, referenceParameters, service, port, portType, metadata, wsdlAddress, wsdlTargetNamespace, attributes);
// write extensibility elements in the EPR element
if (extns != null) {
for (EPRExtension e : extns) {
XMLStreamReaderToXMLStreamWriter c = new XMLStreamReaderToXMLStreamWriter();
XMLStreamReader r = e.readAsXMLStreamReader();
c.bridge(r, writer);
XMLStreamReaderFactory.recycle(r);
}
}
writer.writeEndElement();
writer.writeEndDocument();
writer.flush();
return writer.getXMLStreamBuffer();
} catch (XMLStreamException e) {
throw new WebServiceException(e);
}
}
Aggregations