public static String toString(Packet packet) { if (packet == null) { return "[ Null packet ]"; } else if (packet.getMessage() == null) { return "[ Empty packet ]"; } return toString(packet.getMessage()); }
public static Map<String, List<String>> getTransportHeaders(Packet packet, boolean inbound) { Map<String, List<String>> headers = null; String key = inbound ? Packet.INBOUND_TRANSPORT_HEADERS : Packet.OUTBOUND_TRANSPORT_HEADERS; if (packet.supports(key)) { headers = (Map<String, List<String>>)packet.get(key); } return headers; }
private Packet packet(Message m) { final Packet p = new Packet(); //TODO when do we use xmlCodec? p.codec = soapCodec; if (m != null) p.setMessage(m); MTOMFeature mf = features.get(MTOMFeature.class); if (mf != null) { p.setMtomFeature(mf); } p.setSAAJFactory(saajFactory); return p; }
public boolean containsKey(Object obj) { // First check our property bag if(packet.supports(obj)) { return packet.containsKey(obj); } return packet.invocationProperties.containsKey(obj); }
public boolean containsKey(Object key) { if(packet.supports(key)) return packet.containsKey(key); // strongly typed if(packet.invocationProperties.containsKey(key)) // if handler-scope, hide it return !packet.getHandlerScopePropertyNames(true).contains(key); return false; }
public Object get(Object key) { if(packet.supports(key)) return packet.get(key); // strongly typed if(packet.getHandlerScopePropertyNames(true).contains(key)) return null; // no such application-scope property Object value = packet.invocationProperties.get(key); //add the attachments from the Message to the corresponding attachment property if(key.equals(MessageContext.INBOUND_MESSAGE_ATTACHMENTS)){ Map<String, DataHandler> atts = (Map<String, DataHandler>) value; if(atts == null) atts = new HashMap<String, DataHandler>(); AttachmentSet attSet = packet.getMessage().getAttachments(); for(Attachment att : attSet){ atts.put(att.getContentId(), att.asDataHandler()); } return atts; } return value; }
Packet responsePacket = createClientResponse(responseMessage); responsePacket.setState(State.ServerResponse); String inputAction = AddressingUtils.getAction(this.getMessage().getHeaders(), addressingVersion, soapVersion); if (inputAction == null) { return responsePacket; populateAddressingHeaders(responsePacket, addressingVersion, soapVersion, action, false); return responsePacket;
@Override public @NotNull NextAction processResponse(Packet response) { // if one-way then, no validation if (response.getMessage() != null) { response = validateInboundHeaders(response); response.addSatellite(new WsaPropertyBag(addressingVersion,soapVersion,response)); String msgId = AddressingUtils. getMessageID(response.getMessage().getHeaders(), addressingVersion, soapVersion); response.put(WsaPropertyBag.WSA_MSGID_FROM_REQUEST, msgId); } return doReturnWith(response); }
MessageHeaders hl = packet.getMessage().getHeaders(); String action = AddressingUtils.getAction(hl, binding.getAddressingVersion(), binding.getSOAPVersion()); if (action != null) { if (!oneway && packet.getMessage() != null && packet.getWSDLOperation() != null) { WSDLBoundOperation wbo = wsdlPort.getBinding().get(packet.getWSDLOperation()); if (wbo != null && wbo.getAnonymous() == WSDLBoundOperation.ANONYMOUS.prohibited) { throw new WebServiceException(AddressingMessages.WSAW_ANONYMOUS_PROHIBITED()); final AddressingPropertySet addressingPropertySet = packet.getSatellite(AddressingPropertySet.class); oneWayFeature = addressingPropertySet == null ? oneWayFeature : new OneWayFeature(addressingPropertySet, addressingVersion);
@Override protected Packet getResponse(Packet request, Exception e, WSDLPort port, WSBinding binding) { Packet response = super.getResponse(request, e, port, binding); if (e instanceof HTTPException) { if (response.supports(MessageContext.HTTP_RESPONSE_CODE)) { response.put(MessageContext.HTTP_RESPONSE_CODE, ((HTTPException)e).getStatusCode()); } } return response; }
protected void updateMessage() { //If LogicalMessage is not acccessed, its not modified. if(lm != null) { //Check if LogicalMessageImpl has changed, if so construct new one // Packet are handled through MessageContext if(lm.isPayloadModifed()){ Message msg = packet.getMessage(); Message updatedMsg = lm.getMessage(msg.getHeaders(),msg.getAttachments(),binding); packet.setMessage(updatedMsg); } lm = null; } }
void setPacketMessage(Message newMessage){ if(newMessage != null) { packet.setMessage(newMessage); lm = null; } }
@Override public Object put(String key, Object value) { if (packet.supports(key)) { return packet.put(key, value); // strongly typed } Object old = packet.invocationProperties.get(key); if (old != null) { if (packet.getHandlerScopePropertyNames(true).contains(key)) { throw new IllegalArgumentException("Cannot overwrite property in HANDLER scope"); } // Overwrite existing APPLICATION scoped property packet.invocationProperties.put(key, value); return old; } // No existing property. So Add a new property packet.invocationProperties.put(key, value); return null; }
public @NotNull T resolve(Packet request) { HttpServletRequest sr = (HttpServletRequest) request.get(MessageContext.SERVLET_REQUEST); if(sr==null) throw new WebServiceException( clazz+" has @"+ HttpSessionScope.class.getSimpleName()+" but it's deployed on non-servlet endpoint"); HttpSession session = sr.getSession(); T o = clazz.cast(session.getAttribute(clazz.getName())); if(o==null) { o = create(); session.setAttribute(clazz.getName(),o); } return o; } }
@Override public SOAPMessage getAsSOAPMessage() throws SOAPException { Message msg = this.getMessage(); if (msg == null) return null; if (msg instanceof MessageWritable) ((MessageWritable) msg).setMTOMConfiguration(mtomFeature); return msg.readAsSOAPMessage(this, this.getState().isInbound()); }
@Override Packet createPacket(Message msg) { return new Packet(msg); } }
/** * Creates a server-side response {@link Packet} from a request * packet ({@code this}). If WS-Addressing is enabled, a default Action * Message Addressing Property is obtained using <code>wsdlPort</code> {@link WSDLPort} * and <code>binding</code> {@link WSBinding}. * <p><p> * This method should be called to create application response messages * since they are associated with a {@link WSBinding} and {@link WSDLPort}. * For creating protocol messages that require a non-default Action, use * {@link #createServerResponse(Message, com.sun.xml.ws.api.addressing.AddressingVersion, com.sun.xml.ws.api.SOAPVersion, String)}. * * @param responseMessage The {@link Message} that represents a reply. Can be null. * @param wsdlPort The response WSDL port. * @param binding The response Binding. Cannot be null. * @return response packet */ public Packet createServerResponse(@Nullable Message responseMessage, @Nullable WSDLPort wsdlPort, @Nullable SEIModel seiModel, @NotNull WSBinding binding) { Packet r = createClientResponse(responseMessage); return relateServerResponse(r, wsdlPort, seiModel, binding); }
@Override public Object put(String key, Object value) { if (supports(key)) return asMap.put(key, value); return invocationProperties.put(key, value); }
fCodec.encode(p, fOutputStream); return p.createClientResponse(null);
protected final WSDLBoundOperation getWSDLBoundOperation(Packet packet) { //we can find Req/Response or Oneway only with WSDLModel if(wsdlPort == null) return null; QName opName = packet.getWSDLOperation(); if(opName != null) return wsdlPort.getBinding().get(opName); return null; }