use of com.sun.xml.ws.api.EndpointAddress in project metro-jax-ws by eclipse-ee4j.
the class RewritingMOM method createManagedObjectManager.
/**
* Client monitoring is OFF by default because there is
* no standard stub.close() method. Therefore people do
* not typically close a stub when they are done with it
* (even though the RI does provide a .close).
* <pre>
* prop | no assert | assert/no mon | assert/mon off | assert/mon on
* -------------------------------------------------------------------
* not set | off | off | off | on
* false | off | off | off | off
* true | on | on | off | on
* </pre>
*/
@NotNull
public ManagedObjectManager createManagedObjectManager(final Stub stub) {
EndpointAddress ea = stub.requestContext.getEndpointAddress();
if (ea == null) {
return ManagedObjectManagerFactory.createNOOP();
}
String rootName = ea.toString();
final ManagedClientAssertion assertion = ManagedClientAssertion.getAssertion(stub.getPortInfo());
if (assertion != null) {
final String id = assertion.getId();
if (id != null) {
rootName = id;
}
if (assertion.monitoringAttribute() == Setting.OFF) {
return disabled("This client", rootName);
} else if (assertion.monitoringAttribute() == Setting.ON && clientMonitoring != Setting.OFF) {
return createMOMLoop(rootName, 0);
}
}
if (clientMonitoring == Setting.NOT_SET || clientMonitoring == Setting.OFF) {
return disabled("Global client", rootName);
}
return createMOMLoop(rootName, 0);
}
use of com.sun.xml.ws.api.EndpointAddress 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.EndpointAddress in project metro-jax-ws by eclipse-ee4j.
the class TubelineAssemblerFactoryImplTest method getClientContext.
private ClientTubeAssemblerContext getClientContext(final BindingID bindingId, final Container container) {
final WSBinding binding = bindingId.createBinding();
final EndpointAddress address = new EndpointAddress(ADDRESS_URL);
final WSDLPort port = null;
final QName serviceName = new QName(NAMESPACE, "Service1Service");
WSService service = WSService.create(serviceName);
final QName portName = new QName(NAMESPACE, "Service1Port");
// Corresponds to Service.addPort(portName, bindingId, address)
service.addPort(portName, bindingId.toString(), ADDRESS_URL.toString());
final WSPortInfo portInfo = ((WSServiceDelegate) service).safeGetPort(portName);
WSBindingProvider wsbp = new WSBindingProvider() {
public void setOutboundHeaders(List<Header> headers) {
throw new UnsupportedOperationException("Not supported yet.");
}
public void setOutboundHeaders(Header... headers) {
throw new UnsupportedOperationException("Not supported yet.");
}
public void setOutboundHeaders(Object... headers) {
throw new UnsupportedOperationException("Not supported yet.");
}
public List<Header> getInboundHeaders() {
throw new UnsupportedOperationException("Not supported yet.");
}
public void setAddress(String address) {
throw new UnsupportedOperationException("Not supported yet.");
}
public WSEndpointReference getWSEndpointReference() {
throw new UnsupportedOperationException("Not supported yet.");
}
public WSPortInfo getPortInfo() {
return portInfo;
}
public Map<String, Object> getRequestContext() {
throw new UnsupportedOperationException("Not supported yet.");
}
public Map<String, Object> getResponseContext() {
throw new UnsupportedOperationException("Not supported yet.");
}
public Binding getBinding() {
return binding;
}
public EndpointReference getEndpointReference() {
throw new UnsupportedOperationException("Not supported yet.");
}
public <T extends EndpointReference> T getEndpointReference(Class<T> clazz) {
throw new UnsupportedOperationException("Not supported yet.");
}
public void close() throws IOException {
throw new UnsupportedOperationException("Not supported yet.");
}
public ManagedObjectManager getManagedObjectManager() {
return null;
}
public Set<Component> getComponents() {
throw new UnsupportedOperationException("Not supported yet.");
}
public <S> S getSPI(Class<S> type) {
throw new UnsupportedOperationException("Not supported yet.");
}
};
final ClientTubeAssemblerContext context = new ClientTubeAssemblerContext(address, port, wsbp, binding, container, ((BindingImpl) binding).createCodec(), null, null);
return context;
}
use of com.sun.xml.ws.api.EndpointAddress in project metro-jax-ws by eclipse-ee4j.
the class TubelineAssemblerFactoryImplTest method testDispatch.
/**
* Execute a sequence that corresponds to:
* <pre>
* Service.createService(null, serviceName);
* Service.addPort(portName, bindingId, address);
* </pre>
*/
private Tube testDispatch(String configFileName) throws PolicyException {
final URL wsdlLocation = null;
final QName serviceName = new QName(NAMESPACE, "Service1Service");
// Corresponds to Service.createService(wsdlLocation, serviceName)
final WSServiceDelegate serviceDelegate = new WSServiceDelegate(wsdlLocation, serviceName, Service.class);
final QName portName = new QName(NAMESPACE, "Service1Port");
final BindingID bindingId = BindingID.SOAP11_HTTP;
// Corresponds to Service.addPort(portName, bindingId, address)
serviceDelegate.addPort(portName, bindingId.toString(), ADDRESS_URL.toString());
final EndpointAddress address = new EndpointAddress(ADDRESS_URL);
final WSDLPort port = null;
final WSPortInfo portInfo = serviceDelegate.safeGetPort(portName);
final WSBinding binding = bindingId.createBinding(new AddressingFeature(true));
final Container container = MockupMetroConfigLoader.createMockupContainer("tubes-config/" + configFileName);
WSBindingProvider wsbp = new WSBindingProvider() {
public void setOutboundHeaders(List<Header> headers) {
throw new UnsupportedOperationException("Not supported yet.");
}
public void setOutboundHeaders(Header... headers) {
throw new UnsupportedOperationException("Not supported yet.");
}
public void setOutboundHeaders(Object... headers) {
throw new UnsupportedOperationException("Not supported yet.");
}
public List<Header> getInboundHeaders() {
throw new UnsupportedOperationException("Not supported yet.");
}
public void setAddress(String address) {
throw new UnsupportedOperationException("Not supported yet.");
}
public WSEndpointReference getWSEndpointReference() {
throw new UnsupportedOperationException("Not supported yet.");
}
public WSPortInfo getPortInfo() {
return portInfo;
}
public Map<String, Object> getRequestContext() {
throw new UnsupportedOperationException("Not supported yet.");
}
public Map<String, Object> getResponseContext() {
throw new UnsupportedOperationException("Not supported yet.");
}
public Binding getBinding() {
return binding;
}
public EndpointReference getEndpointReference() {
throw new UnsupportedOperationException("Not supported yet.");
}
public <T extends EndpointReference> T getEndpointReference(Class<T> clazz) {
throw new UnsupportedOperationException("Not supported yet.");
}
public void close() throws IOException {
throw new UnsupportedOperationException("Not supported yet.");
}
public ManagedObjectManager getManagedObjectManager() {
return null;
}
public Set<Component> getComponents() {
throw new UnsupportedOperationException("Not supported yet.");
}
public <S> S getSPI(Class<S> type) {
throw new UnsupportedOperationException("Not supported yet.");
}
};
final ClientTubeAssemblerContext context = new ClientTubeAssemblerContext(address, port, wsbp, binding, container, ((BindingImpl) binding).createCodec(), null, null);
return getAssembler(bindingId).createClient(context);
}
use of com.sun.xml.ws.api.EndpointAddress in project metro-jax-ws by eclipse-ee4j.
the class RuntimeWSDLParser method parsePort.
private void parsePort(XMLStreamReader reader, EditableWSDLService service) {
port_nsdecl.putAll(service_nsdecl);
readNSDecl(port_nsdecl, reader);
String portName = ParserUtil.getMandatoryNonEmptyAttribute(reader, WSDLConstants.ATTR_NAME);
String binding = ParserUtil.getMandatoryNonEmptyAttribute(reader, "binding");
QName bindingName = ParserUtil.getQName(reader, binding);
QName portQName = new QName(service.getName().getNamespaceURI(), portName);
EditableWSDLPort port = new WSDLPortImpl(reader, service, portQName, bindingName);
extensionFacade.portAttributes(port, reader);
String location;
while (XMLStreamReaderUtil.nextElementContent(reader) != XMLStreamConstants.END_ELEMENT) {
QName name = reader.getName();
if (SOAPConstants.QNAME_ADDRESS.equals(name) || SOAPConstants.QNAME_SOAP12ADDRESS.equals(name)) {
location = ParserUtil.getMandatoryNonEmptyAttribute(reader, WSDLConstants.ATTR_LOCATION);
if (location != null) {
try {
port.setAddress(new EndpointAddress(location));
} catch (URISyntaxException e) {
// Lets not throw any exception, latter on it should be thrown when invocation happens. At this
// time user has option to set the endopint address using request contexxt property.
}
}
XMLStreamReaderUtil.next(reader);
} else if (AddressingVersion.W3C.nsUri.equals(name.getNamespaceURI()) && "EndpointReference".equals(name.getLocalPart())) {
try {
StreamReaderBufferCreator creator = new StreamReaderBufferCreator(new MutableXMLStreamBuffer());
XMLStreamBuffer eprbuffer = new XMLStreamBufferMark(port_nsdecl, creator);
creator.createElementFragment(reader, false);
WSEndpointReference wsepr = new WSEndpointReference(eprbuffer, AddressingVersion.W3C);
// wsepr.toSpec().writeTo(new StreamResult(System.out));
port.setEPR(wsepr);
/* XMLStreamBuffer.createNewBufferFromXMLStreamReader(reader) called from inside WSEndpointReference()
consumes the complete EPR infoset and moves to the next element. This breaks the normal wsdl parser
processing where it expects anyone reading the infoset to move to the end of the element that its reading
and not to the next element.
*/
if (reader.getEventType() == XMLStreamConstants.END_ELEMENT && reader.getName().equals(WSDLConstants.QNAME_PORT))
break;
} catch (XMLStreamException e) {
throw new WebServiceException(e);
}
} else {
extensionFacade.portElements(port, reader);
}
}
if (port.getAddress() == null) {
try {
port.setAddress(new EndpointAddress(""));
} catch (URISyntaxException e) {
// Lets not throw any exception, latter on it should be thrown when invocation happens. At this
// time user has option to set the endopint address using request contexxt property.
}
}
service.put(portQName, port);
port_nsdecl = new HashMap<>();
}
Aggregations