public AddressingProperties createCompatibleResponseProperties() { return new AddressingProperties(getNamespaceURI()); } }
public MAP newMap() { AddressingProperties implementation = new AddressingProperties(); return new CXFMAP(implementation); }
public AddressingProperties createCompatibleResponseProperties() { return new AddressingProperties(getNamespaceURI()); } }
/** * retrieve the outbound client message address properties attached to a message request map * @param ctx the client request properties map * @return */ public MAP outboundMap(Map<String, Object> ctx) { AddressingProperties implementation = (AddressingProperties)ctx.get(CXFMAPConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND); if (implementation == null) { implementation = new AddressingProperties(); ctx.put(CXFMAPConstants.CLIENT_ADDRESSING_PROPERTIES, implementation); ctx.put(CXFMAPConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND, implementation); } return newMap(implementation); }
private static AddressingProperties initAddressingProperties(SoapMessage message) { AddressingProperties maps = (AddressingProperties) message.getContextualProperty( JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES); if (maps == null) { maps = new AddressingProperties(); message.put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES, maps); } return maps; }
/** * Get the starting point MAPs (either empty or those set explicitly * by the application on the binding provider request context). * * @param message the current message * @param isProviderContext true if the binding provider request context * available to the client application as opposed to the message context * visible to handlers * @param isOutbound true iff the message is outbound * @return AddressingProperties retrieved MAPs */ private AddressingProperties getMAPs(Message message, boolean isProviderContext, boolean isOutbound) { AddressingProperties maps = null; maps = ContextUtils.retrieveMAPs(message, isProviderContext, isOutbound); LOG.log(Level.FINE, "MAPs retrieved from message {0}", maps); if (maps == null && isProviderContext) { maps = new AddressingProperties(); setupNamespace(maps, message); } return maps; }
/** * Get the starting point MAPs (either empty or those set explicitly * by the application on the binding provider request context). * * @param message the current message * @param isProviderContext true if the binding provider request context * available to the client application as opposed to the message context * visible to handlers * @param isOutbound true iff the message is outbound * @return AddressingProperties retrieved MAPs */ private AddressingProperties getMAPs(Message message, boolean isProviderContext, boolean isOutbound) { AddressingProperties maps = null; maps = ContextUtils.retrieveMAPs(message, isProviderContext, isOutbound); LOG.log(Level.FINE, "MAPs retrieved from message {0}", maps); if (maps == null && isProviderContext) { maps = new AddressingProperties(); setupNamespace(maps, message); } return maps; }
@Override public void handleMessage(Message pMessage) throws Fault { AttributedURIType uri = new AttributedURIType(); uri.setValue(getWSAddressingToUri()); AddressingProperties maps = new AddressingProperties(); maps.setTo(uri); pMessage.put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES, maps); }
public void handleMessage(SoapMessage message) throws Fault { AddressingProperties inProps = (AddressingProperties)message .getContextualProperty(JAXWSAConstants.ADDRESSING_PROPERTIES_INBOUND); AddressingProperties outProps = (AddressingProperties)message .getContextualProperty(JAXWSAConstants.ADDRESSING_PROPERTIES_OUTBOUND); if (inProps != null) { if (outProps == null) { outProps = new AddressingProperties(inProps.getNamespaceURI()); } AttributedURIType action = new AttributedURIType(); action.setValue(inProps.getAction().getValue().replace("/RST/", "/RSTR/")); outProps.setAction(action); message.put(JAXWSAConstants.ADDRESSING_PROPERTIES_OUTBOUND, outProps); } }
public void handleMessage(SoapMessage message) throws Fault { AddressingProperties inProps = (AddressingProperties)message .getContextualProperty(JAXWSAConstants.ADDRESSING_PROPERTIES_INBOUND); AddressingProperties outProps = (AddressingProperties)message .getContextualProperty(JAXWSAConstants.ADDRESSING_PROPERTIES_OUTBOUND); if (inProps != null) { if (outProps == null) { outProps = new AddressingProperties(inProps.getNamespaceURI()); } AttributedURIType action = new AttributedURIType(); action.setValue(inProps.getAction().getValue().replace("/RST/", "/RSTR/")); outProps.setAction(action); message.put(JAXWSAConstants.ADDRESSING_PROPERTIES_OUTBOUND, outProps); } }
/** * Initializes WS-Addressing headers MessageID and ReplyTo, * and stores them into the given message context. */ private static void configureWSAHeaders(String messageId, String replyToUri, WrappedMessageContext context) { // obtain headers' container AddressingProperties apropos = (AddressingProperties) context.get(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES); if (apropos == null) { apropos = new AddressingProperties(); context.put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES, apropos); } // MessageID header AttributedURIType uri = new AttributedURIType(); uri.setValue(messageId); apropos.setMessageID(uri); LOG.debug("Set WS-Addressing message ID: {}", messageId); // ReplyTo header if (replyToUri != null) { AttributedURIType uri2 = new AttributedURIType(); uri2.setValue(replyToUri); EndpointReferenceType endpointReference = new EndpointReferenceType(); endpointReference.setAddress(uri2); apropos.setReplyTo(endpointReference); } }
private void updateOutputAction(String append) { AddressingProperties p = ContextUtils.retrieveMAPs(PhaseInterceptorChain.getCurrentMessage(), false, false); AddressingProperties pout = new AddressingProperties(); AttributedURIType action = new AttributedURIType(); action.setValue(p.getAction().getValue() + append); pout.exposeAs(p.getNamespaceURI()); pout.setAction(action); ContextUtils.storeMAPs(pout, PhaseInterceptorChain.getCurrentMessage(), true); }
private void updateOutputAction(String append) { AddressingProperties p = ContextUtils.retrieveMAPs(PhaseInterceptorChain.getCurrentMessage(), false, false); AddressingProperties pout = new AddressingProperties(); AttributedURIType action = new AttributedURIType(); action.setValue(p.getAction().getValue() + append); pout.exposeAs(p.getNamespaceURI()); pout.setAction(action); ContextUtils.storeMAPs(pout, PhaseInterceptorChain.getCurrentMessage(), true); }
@Test public void testOneWayFaultTo() throws Exception { URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl"); QName serviceName = new QName("http://apache.org/hello_world_soap_http", "SOAPServiceAddressing"); Greeter greeter = new SOAPService(wsdl, serviceName).getPort(Greeter.class, new AddressingFeature()); EndpointReferenceType faultTo = new EndpointReferenceType(); AddressingProperties addrProperties = new AddressingProperties(); AttributedURIType epr = new AttributedURIType(); String faultToAddress = "http://localhost:" + FaultToEndpointServer.FAULT_PORT + "/faultTo"; epr.setValue(faultToAddress); faultTo.setAddress(epr); addrProperties.setFaultTo(faultTo); BindingProvider provider = (BindingProvider) greeter; Map<String, Object> requestContext = provider.getRequestContext(); requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + FaultToEndpointServer.PORT + "/jaxws/greeter"); requestContext.put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES, addrProperties); greeter.greetMeOneWay("test"); //wait for the fault request int i = 2; while (HelloHandler.getFaultRequestPath() == null && i > 0) { Thread.sleep(500); i--; } assertTrue("FaultTo request fpath isn't expected", "/faultTo".equals(HelloHandler.getFaultRequestPath())); }
/** * check if MessageID exists in the message, if not, only generate new MessageID for outbound message. * @param message */ private void checkMessageID(Message message) { if (!MessageUtils.isOutbound(message)) return; AddressingProperties maps = ContextUtils.retrieveMAPs(message, false, MessageUtils.isOutbound(message)); if (maps == null) { maps = new AddressingProperties(); } if (maps.getMessageID() == null) { String messageID = ContextUtils.generateUUID(); boolean isRequestor = ContextUtils.isRequestor(message); maps.setMessageID(ContextUtils.getAttributedURI(messageID)); ContextUtils.storeMAPs(maps, message, ContextUtils.isOutbound(message), isRequestor); } }
/** * check if MessageID exists in the message, if not, only generate new MessageID for outbound message. * @param message */ private void checkMessageID(Message message) { if (!MessageUtils.isOutbound(message)) return; AddressingProperties maps = ContextUtils.retrieveMAPs(message, false, MessageUtils.isOutbound(message)); if (maps == null) { maps = new AddressingProperties(); } if (maps.getMessageID() == null) { String messageID = ContextUtils.generateUUID(); boolean isRequestor = ContextUtils.isRequestor(message); maps.setMessageID(ContextUtils.getAttributedURI(messageID)); ContextUtils.storeMAPs(maps, message, ContextUtils.isOutbound(message), isRequestor); } }
/** * Construct and store MAPs for partial response. * * @param partialResponse the partial response message * @param namespaceURI the current namespace URI */ private static void ensurePartialResponseMAPs(Message partialResponse, String namespaceURI) { // ensure there is a MAPs instance available for the outbound // partial response that contains appropriate To and ReplyTo // properties (i.e. anonymous & none respectively) AddressingProperties maps = new AddressingProperties(); maps.setTo(EndpointReferenceUtils.getAnonymousEndpointReference()); maps.setReplyTo(ContextUtils.WSA_OBJECT_FACTORY.createEndpointReferenceType()); maps.getReplyTo().setAddress(ContextUtils.getAttributedURI(Names.WSA_NONE_ADDRESS)); maps.setAction(ContextUtils.getAttributedURI("")); maps.exposeAs(namespaceURI); ContextUtils.storeMAPs(maps, partialResponse, true, true, false); }
/** * Construct and store MAPs for partial response. * * @param partialResponse the partial response message * @param namespaceURI the current namespace URI */ private static void ensurePartialResponseMAPs(Message partialResponse, String namespaceURI) { // ensure there is a MAPs instance available for the outbound // partial response that contains appropriate To and ReplyTo // properties (i.e. anonymous & none respectively) AddressingProperties maps = new AddressingProperties(); maps.setTo(EndpointReferenceUtils.getAnonymousEndpointReference()); maps.setReplyTo(ContextUtils.WSA_OBJECT_FACTORY.createEndpointReferenceType()); maps.getReplyTo().setAddress(ContextUtils.getAttributedURI(Names.WSA_NONE_ADDRESS)); maps.setAction(ContextUtils.getAttributedURI("")); maps.exposeAs(namespaceURI); ContextUtils.storeMAPs(maps, partialResponse, true, true, false); }
/** * Construct and store MAPs for partial response. * * @param partialResponse the partial response message * @param namespaceURI the current namespace URI */ private static void ensurePartialResponseMAPs(Message partialResponse, String namespaceURI) { // ensure there is a MAPs instance available for the outbound // partial response that contains appropriate To and ReplyTo // properties (i.e. anonymous & none respectively) AddressingProperties maps = new AddressingProperties(); maps.setTo(EndpointReferenceUtils.getAnonymousEndpointReference()); maps.setReplyTo(ContextUtils.WSA_OBJECT_FACTORY.createEndpointReferenceType()); maps.getReplyTo().setAddress(ContextUtils.getAttributedURI(Names.WSA_NONE_ADDRESS)); maps.setAction(ContextUtils.getAttributedURI("")); maps.exposeAs(namespaceURI); ContextUtils.storeMAPs(maps, partialResponse, true, true, false); }
@Test public void testNonAnonToAnon() throws Exception { try (AddNumbersPortTypeProxy port = getPort()) { port.getRequestContext() .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/jaxws/addAnon"); AddressingProperties maps = new AddressingProperties(); EndpointReferenceType ref = new EndpointReferenceType(); AttributedURIType add = new AttributedURIType(); add.setValue("http://localhost:" + INVALID_PORT + "/not/a/real/url"); ref.setAddress(add); maps.setReplyTo(ref); maps.setFaultTo(ref); port.getRequestContext() .put("javax.xml.ws.addressing.context", maps); try { port.addNumbers3(-1, 2); } catch (SOAPFaultException e) { assertTrue(e.getFault().getFaultCode().contains("OnlyAnonymousAddressSupported")); } } } private AddNumbersPortTypeProxy getPort()throws Exception {