/** * Creates a <code>XFireFault</code> from the given throwable. If the throwable is a <code>XFireFault</code>, it is * not wrapped. * * @param throwable the throwable * @return the fault */ public static XFireFault createFault(Throwable throwable) { XFireFault fault = null; if (throwable instanceof XFireFault) { fault = (XFireFault) throwable; } else { fault = new XFireFault(throwable); } return fault; }
/** * Loads the property descriptors for the ordered properties of the specified class. * * @param wrapperClass The wrapper class. * @return The ordered property descriptors. */ protected PropertyDescriptor[] loadOrderedProperties(Class wrapperClass) throws XFireFault { String[] propOrder = annotations.getPropertyOrder(wrapperClass); if (propOrder == null) { throw new XFireFault("Unable use use " + wrapperClass.getName() + " as a wrapper class: no propOrder specified.", XFireFault.RECEIVER); } BeanInfo responseBeanInfo; try { responseBeanInfo = Introspector.getBeanInfo(wrapperClass, Object.class); } catch (IntrospectionException e) { throw new XFireFault("Unable to introspect " + wrapperClass.getName(), e, XFireFault.RECEIVER); } return PropertyUtil.sortProperties(wrapperClass, responseBeanInfo.getPropertyDescriptors(), propOrder); }
/** * Loads the property descriptors for the ordered properties of the specified class. * * @param wrapperClass The wrapper class. * @return The ordered property descriptors. */ protected PropertyDescriptor[] loadOrderedProperties(Class wrapperClass) throws XFireFault { String[] propOrder = annotations.getPropertyOrder(wrapperClass); if (propOrder == null) { throw new XFireFault("Unable use use " + wrapperClass.getName() + " as a wrapper class: no propOrder specified.", XFireFault.RECEIVER); } BeanInfo responseBeanInfo; try { responseBeanInfo = Introspector.getBeanInfo(wrapperClass, Object.class); } catch (IntrospectionException e) { throw new XFireFault("Unable to introspect " + wrapperClass.getName(), e, XFireFault.RECEIVER); } return PropertyUtil.sortProperties(wrapperClass, responseBeanInfo.getPropertyDescriptors(), propOrder); }
/** * Reads the bytes of the specified data handler to a byte array. * * @param dataHandler The data handler to read. * @return The bytes that were read. */ public static byte[] readBytes(DataHandler dataHandler) throws XFireFault { ByteArrayOutputStream out = new ByteArrayOutputStream(); try { InputStream in = dataHandler.getInputStream(); byte[] inBytes = new byte[1024 * 10]; //10 K? int len; while ((len = in.read(inBytes)) > 0) { out.write(inBytes, 0, len); } return out.toByteArray(); } catch (IOException e) { throw new XFireFault(e, XFireFault.RECEIVER); } }
protected Object getClientParam(Object[] values, MessagePartInfo outParam, MessageContext context) throws XFireFault { if (outParam.getIndex() >= values.length) { throw new XFireFault("Not enough input parameters were supplied!", XFireFault.SENDER); } return values[outParam.getIndex()]; }
public Object getServiceObject(MessageContext context) throws XFireFault{ try{ return getScopedFactory(context).create(); } catch(XFireFault e){ throw e; } catch(Throwable e){ throw new XFireFault(e); } } private Factory getScopedFactory(MessageContext context){
public void writeMessage(OutMessage out, XMLStreamWriter writer, MessageContext ctx) throws XFireFault { try { STAXUtils.copy((XMLStreamReader) out.getBody(), writer); } catch (XMLStreamException e) { throw new XFireFault("Couldn't write to stream.", e, XFireFault.RECEIVER); } } }
public EnunciatedJAXWSOperationBinding(OperationInfo op) throws XFireFault { this.requestInfo = getRequestInfo(op); this.responseInfo = getResponseInfo(op); ArrayList<Class> contextClasses = new ArrayList<Class>(2); if (this.requestInfo != null) { contextClasses.add(this.requestInfo.getBeanClass()); } if (this.responseInfo != null) { contextClasses.add(this.responseInfo.getBeanClass()); } try { this.jaxbContext = JAXBContext.newInstance(contextClasses.toArray(new Class[contextClasses.size()])); } catch (JAXBException e) { throw new XFireFault("Unable to create a binding for " + op.getMethod() + ".", e, XFireFault.RECEIVER); } }
private void assertSingle(Element root, String tagName, Namespace wsa) throws XFireFault { List list = root.getChildren(tagName,wsa); if( list!= null ){ if(list.size()> 1){ XFireFault fault = new XFireFault("Invalid header",new QName(wsa.getURI(),"Sender")); fault.addNamespace("wsa",wsa.getURI()); fault.setSubCode(new QName(wsa.getURI(),"InvalidAddressingHeader")); Element detail = new Element("ProblemHeaderQName",wsa); detail.addContent(tagName); fault.setDetail(detail); throw fault; } } }
public EnunciatedJAXWSOperationBinding(OperationInfo op) throws XFireFault { this.requestInfo = getRequestInfo(op); this.responseInfo = getResponseInfo(op); ArrayList<Class> contextClasses = new ArrayList<Class>(2); if (this.requestInfo != null) { contextClasses.add(this.requestInfo.getBeanClass()); } if (this.responseInfo != null) { contextClasses.add(this.responseInfo.getBeanClass()); } try { this.jaxbContext = JAXBContext.newInstance(contextClasses.toArray(new Class[contextClasses.size()])); } catch (JAXBException e) { throw new XFireFault("Unable to create a binding for " + op.getMethod() + ".", e, XFireFault.RECEIVER); } }
public void writeMessage(OutMessage message, XMLStreamWriter writer, MessageContext context) throws XFireFault { Document doc = (Document) message.getBody(); StaxSerializer serializer = new StaxSerializer(); try { serializer.writeElement(doc.getRootElement(), writer); } catch (XMLStreamException e) { throw new XFireFault("Couldn't write message.", e, XFireFault.RECEIVER); } }
/** * Assert that a service understands a particular header. If not, a fault is thrown. * * @param context * @param name * @throws XFireFault */ protected void assertUnderstandsHeader(MessageContext context, QName name) throws XFireFault { if (context.getInPipeline().understands(name)) return; if (context.getOutPipeline().understands(name)) return; // TODO: Check Out pipeline for understanding throw new XFireFault("Header {" + name.getLocalPart() + "}" + name.getNamespaceURI() + " was not undertsood by the service.", XFireFault.MUST_UNDERSTAND); } }
protected void handleFault(MessageContext context, XFireFault fault, Throwable cause, MessagePartInfo faultPart) throws XFireFault { JDOMStreamWriter writer = new JDOMStreamWriter(fault.getDetail()); Object faultBean = getFaultBean(cause, faultPart, context); try { AbstractBinding.writeParameter(writer, context, faultBean, faultPart, faultPart.getName().getNamespaceURI()); } catch (XMLStreamException e) { throw new XFireFault("Could not write to outgoing stream.", e, XFireFault.RECEIVER); } }
public void readMessage(InMessage message, MessageContext context) throws XFireFault { StaxBuilder builder = new StaxBuilder(); try { Document doc = builder.build(message.getXMLStreamReader()); message.setBody(doc); } catch (XMLStreamException e) { throw new XFireFault("Couldn't parse message.", e, XFireFault.SENDER); } }
public void readMessage(InMessage message, MessageContext context) throws XFireFault { if (message.getSoapVersion() instanceof Soap11) soap11.readMessage(message, context); else if (message.getSoapVersion() instanceof Soap12) soap12.readMessage(message, context); else throw new XFireFault("Unrecognized soap version.", (XFireFault) message.getBody(), XFireFault.SENDER); }
public void writeMessage(OutMessage message, XMLStreamWriter writer, MessageContext context) throws XFireFault { if (message.getSoapVersion() instanceof Soap11) soap11.writeMessage(message, writer, context); else if (message.getSoapVersion() instanceof Soap12) soap12.writeMessage(message, writer, context); else throw new XFireFault("Unrecognized soap version.", (XFireFault) message.getBody(), XFireFault.SENDER); }
public void invoke(MessageContext context) throws Exception { AbstractSoapBinding binding = (AbstractSoapBinding) context.getBinding(); if (binding == null) { throw new XFireFault("Could not find appropriate binding for service: " + context.getService().getName(), XFireFault.RECEIVER); } MessageSerializer ser = binding.getSerializer(context.getExchange().getOperation()); ser.readMessage(context.getInMessage(), context); } }
/** * Writes a message. Delegates to the operation binding of the operation in the current message exchange. * * @param message The message to write. * @param writer The writer to which to write. * @param context The context */ public void writeMessage(OutMessage message, XMLStreamWriter writer, MessageContext context) throws XFireFault { OperationInfo op = context.getExchange().getOperation(); MessageInfo inMessage = op.getInputMessage(); if (inMessage == null) { throw new XFireFault("No request message was found in the current operation!", XFireFault.RECEIVER); } new ElementWriter(writer, inMessage.getName()); getOperationBinding(op).writeMessage(message, writer, context); //the xfire SoapSerializer makes the strange assumption that the message serializer doesn't close its element... //elementWriter.close(); }
/** * Writes a message. Delegates to the operation binding of the operation in the current message exchange. * * @param message The message to write. * @param writer The writer to which to write. * @param context The context */ public void writeMessage(OutMessage message, XMLStreamWriter writer, MessageContext context) throws XFireFault { OperationInfo op = context.getExchange().getOperation(); MessageInfo inMessage = op.getInputMessage(); if (inMessage == null) { throw new XFireFault("No request message was found in the current operation!", XFireFault.RECEIVER); } new ElementWriter(writer, inMessage.getName()); getOperationBinding(op).writeMessage(message, writer, context); //the xfire SoapSerializer makes the strange assumption that the message serializer doesn't close its element... //elementWriter.close(); }
public void readMessage(InMessage message, MessageContext context) throws XFireFault { Service endpoint = context.getService(); DepthXMLStreamReader dr = new DepthXMLStreamReader(context.getInMessage().getXMLStreamReader()); if ( !STAXUtils.toNextElement(dr) ) throw new XFireFault("There must be a method name element.", XFireFault.SENDER); OperationInfo op = context.getExchange().getOperation(); if (!isClientModeOn(context) && op == null) { op = endpoint.getServiceInfo().getOperation( dr.getLocalName() ); if (op != null) { setOperation(op, context); JAXWSOperationBinding opBinding = getOperationBinding(op); opBinding.readMessage(message, context); return; } } delegate.readMessage(message, context); }