use of com.sun.xml.ws.api.addressing.WSEndpointReference in project metro-jax-ws by eclipse-ee4j.
the class ProviderImpl method getPort.
public <T> T getPort(EndpointReference endpointReference, Class<T> clazz, WebServiceFeature... webServiceFeatures) {
/*
final @NotNull MemberSubmissionEndpointReference msepr =
EndpointReferenceUtil.transform(MemberSubmissionEndpointReference.class, endpointReference);
WSService service = new WSServiceDelegate(msepr.toWSDLSource(), msepr.serviceName.name, Service.class);
*/
if (endpointReference == null)
throw new WebServiceException(ProviderApiMessages.NULL_EPR());
WSEndpointReference wsepr = new WSEndpointReference(endpointReference);
WSEndpointReference.Metadata metadata = wsepr.getMetaData();
WSService service;
if (metadata.getWsdlSource() != null)
service = (WSService) createServiceDelegate(metadata.getWsdlSource(), metadata.getServiceName(), Service.class);
else
throw new WebServiceException("WSDL metadata is missing in EPR");
return service.getPort(wsepr, clazz, webServiceFeatures);
}
use of com.sun.xml.ws.api.addressing.WSEndpointReference 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 com.sun.xml.ws.api.addressing.WSEndpointReference in project metro-jax-ws by eclipse-ee4j.
the class AddressingUtils method getFaultTo.
public static WSEndpointReference getFaultTo(@NotNull MessageHeaders headers, @NotNull AddressingVersion av, @NotNull SOAPVersion sv) {
if (av == null) {
throw new IllegalArgumentException(AddressingMessages.NULL_ADDRESSING_VERSION());
}
Header h = getFirstHeader(headers, av.faultToTag, true, sv);
WSEndpointReference faultTo = null;
if (h != null) {
try {
faultTo = h.readAsEPR(av);
} catch (XMLStreamException e) {
throw new WebServiceException(AddressingMessages.FAULT_TO_CANNOT_PARSE(), e);
}
}
return faultTo;
}
use of com.sun.xml.ws.api.addressing.WSEndpointReference in project metro-jax-ws by eclipse-ee4j.
the class AddressingUtils method getReplyTo.
public static WSEndpointReference getReplyTo(@NotNull MessageHeaders headers, @NotNull AddressingVersion av, @NotNull SOAPVersion sv) {
if (av == null) {
throw new IllegalArgumentException(AddressingMessages.NULL_ADDRESSING_VERSION());
}
Header h = getFirstHeader(headers, av.replyToTag, true, sv);
WSEndpointReference replyTo;
if (h != null) {
try {
replyTo = h.readAsEPR(av);
} catch (XMLStreamException e) {
throw new WebServiceException(AddressingMessages.REPLY_TO_CANNOT_PARSE(), e);
}
} else {
replyTo = av.anonymousEpr;
}
return replyTo;
}
use of com.sun.xml.ws.api.addressing.WSEndpointReference in project metro-jax-ws by eclipse-ee4j.
the class AddressingUtils method fillRequestAddressingHeaders.
public static void fillRequestAddressingHeaders(MessageHeaders headers, Packet packet, AddressingVersion av, SOAPVersion sv, boolean oneway, String action, boolean mustUnderstand) {
fillCommonAddressingHeaders(headers, packet, av, sv, action, mustUnderstand);
// null or "true" is equivalent to request/response MEP
if (!oneway) {
WSEndpointReference epr = av.anonymousEpr;
if (headers.get(av.replyToTag, false) == null) {
headers.add(epr.createHeader(av.replyToTag));
}
// wsa:FaultTo
if (headers.get(av.faultToTag, false) == null) {
headers.add(epr.createHeader(av.faultToTag));
}
// wsa:MessageID
if (packet.getMessage().getHeaders().get(av.messageIDTag, false) == null) {
if (headers.get(av.messageIDTag, false) == null) {
Header h = new StringHeader(av.messageIDTag, Message.generateMessageID());
headers.add(h);
}
}
}
}
Aggregations