Package javax.xml.soap

Examples of javax.xml.soap.SOAPMessage


  {
    try
    {
      this.sf = SOAPFactory.newInstance();
      this.connection = createSOAPConnection();
      SOAPMessage queryMessage = createQueryMessage();

      URL soapURL = new URL(getSoapUrl());
      SOAPMessage resultMessage = executeQuery(queryMessage, soapURL);
     
      xmlaResult = new JRXmlaResult();
      parseResult(resultMessage);
    }
    catch (MalformedURLException e)
View Full Code Here


    }
   
    try
    {
      MessageFactory mf = MessageFactory.newInstance();
      SOAPMessage message = mf.createMessage();

      MimeHeaders mh = message.getMimeHeaders();
      mh.setHeader("SOAPAction", "\"urn:schemas-microsoft-com:xml-analysis:Execute\"");

      SOAPPart soapPart = message.getSOAPPart();
      SOAPEnvelope envelope = soapPart.getEnvelope();
      SOAPBody body = envelope.getBody();
      Name nEx = envelope.createName("Execute", "", XMLA_URI);

      SOAPElement eEx = body.addChildElement(nEx);

      // add the parameters

      // COMMAND parameter
      // <Command>
      // <Statement>queryStr</Statement>
      // </Command>
      Name nCom = envelope.createName("Command", "", XMLA_URI);
      SOAPElement eCommand = eEx.addChildElement(nCom);
      Name nSta = envelope.createName("Statement", "", XMLA_URI);
      SOAPElement eStatement = eCommand.addChildElement(nSta);
      eStatement.addTextNode(queryStr);

      // <Properties>
      // <PropertyList>
      // <DataSourceInfo>dataSource</DataSourceInfo>
      // <Catalog>catalog</Catalog>
      // <Format>Multidimensional</Format>
      // <AxisFormat>TupleFormat</AxisFormat>
      // </PropertyList>
      // </Properties>
      Map paraList = new HashMap();
      String datasource = (String) getParameterValue(JRXmlaQueryExecuterFactory.PARAMETER_XMLA_DATASOURCE);
      paraList.put("DataSourceInfo", datasource);
      String catalog = (String) getParameterValue(JRXmlaQueryExecuterFactory.PARAMETER_XMLA_CATALOG);
      paraList.put("Catalog", catalog);
      paraList.put("Format", "Multidimensional");
      paraList.put("AxisFormat", "TupleFormat");
      addParameterList(envelope, eEx, "Properties", "PropertyList", paraList);
      message.saveChanges();

      if (log.isDebugEnabled())
      {
        log.debug("XML/A query message: " + message.toString());
      }

      return message;
    }
    catch (SOAPException e)
View Full Code Here

         {
            EJBArgsPolicyContextHandler.setArgs(mi.getArguments());
         }
         else
         {
            SOAPMessage msg = (SOAPMessage)mi.getValue(InvocationKey.SOAP_MESSAGE);
            SOAPMsgPolicyContextHandler.setMessage(msg);
         }
         // Set custom JACC policy handlers
         BeanMetaDataPolicyContextHandler.setMetaData(this.getBeanMetaData());
View Full Code Here

      SOAPFaultException sfe = (SOAPFaultException) _protocolException;
      SOAPFault fault = sfe.getFault();

      try {
        MessageFactory factory = _soapContext.getMessageFactory();
        SOAPMessage message = factory.createMessage();
        message.getSOAPBody().addChildElement(fault);
        _soapContext.setMessage(message);
        _source = _soapContext.getMessage().getSOAPPart().getContent();
      }
      catch (SOAPException se) {
        throw new WebServiceException(se);
View Full Code Here

  private void serializeRuntimeException()
    throws WebServiceException
  {
    try {
      MessageFactory factory = _soapContext.getMessageFactory();
      SOAPMessage message = factory.createMessage();

      QName faultcode = new QName(message.getSOAPBody().getNamespaceURI(),
                                  "Server",
                                  message.getSOAPBody().getPrefix());

      message.getSOAPBody().addFault(faultcode, _runtimeException.getMessage());

      _soapContext.setMessage(message);
      _source = _soapContext.getMessage().getSOAPPart().getContent();
    }
    catch (SOAPException se) {
View Full Code Here

  }

  public void invoke(InputStream is, OutputStream os)
    throws Throwable
  {
    SOAPMessage request = _factory.createMessage(new MimeHeaders(), is);
    SOAPMessage response = (SOAPMessage) _provider.invoke(request);

    response.writeTo(os);
    os.flush();
  }
View Full Code Here

                // mark as a response and replace envelope from cache
                synCtx.setResponse(true);
                try {
                    MessageFactory mf = MessageFactory.newInstance();
                    SOAPMessage smsg;
                    if (synCtx.isSOAP11()) {
                        smsg = mf.createMessage(new MimeHeaders(),
                                new ByteArrayInputStream(cachedObj.getResponseEnvelope()));
                    } else {
                        MimeHeaders mimeHeaders = new MimeHeaders();
                        mimeHeaders.addHeader("Content-ID", IDGenerator.generateID());
                        mimeHeaders.addHeader("content-type",
                                HTTPConstants.MEDIA_TYPE_APPLICATION_SOAP_XML);
                        smsg = mf.createMessage(mimeHeaders,
                                new ByteArrayInputStream((cachedObj).getResponseEnvelope()));
                    }

                    if (smsg != null) {
                        org.apache.axiom.soap.SOAPEnvelope omSOAPEnv =
                                SAAJUtil.toOMSOAPEnvelope(
                                        smsg.getSOAPPart().getDocumentElement());
                        synCtx.setEnvelope(omSOAPEnv);
                    } else {
                        handleException("Unable to serve from the cache : " +
                                "Couldn't build the SOAP response from the cached byte stream",
                                synCtx);
View Full Code Here

            public boolean handleFault(SOAPMessageContext ctx) {
                super.handleFault(ctx);
                Boolean outbound = (Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
                if (!outbound) {
                    try {
                        SOAPMessage msg = ctx.getMessage();
                        assertNotNull(msg);
                    } catch (Exception e) {
                        e.printStackTrace();
                        fail(e.toString());
                    }
View Full Code Here

        TestSOAPHandler soapHandler2 = new TestSOAPHandler(false);

        addHandlersToChain((BindingProvider)disp, handler1, handler2, soapHandler1, soapHandler2);

        InputStream is = getClass().getResourceAsStream("PingReq.xml");
        SOAPMessage outMsg = MessageFactory.newInstance().createMessage(null, is);

        SOAPMessage inMsg = disp.invoke(outMsg);
        assertNotNull(inMsg);

        assertEquals("handle message was not invoked", 2, handler1.getHandleMessageInvoked());
        assertEquals("handle message was not invoked", 2, handler2.getHandleMessageInvoked());
        assertEquals("handle message was not invoked", 2, soapHandler1.getHandleMessageInvoked());
        assertEquals("handle message was not invoked", 2, soapHandler2.getHandleMessageInvoked());
        
        assertEquals("close must be called", 1, handler1.getCloseInvoked());
        assertEquals("close must be called", 1, handler2.getCloseInvoked());
        assertEquals("close must be called", 1, soapHandler1.getCloseInvoked());
        assertEquals("close must be called", 1, soapHandler2.getCloseInvoked());

        // the server has encoded into the response the order in
        // which the handlers have been invoked, parse it and make
        // sure everything is ok

        // expected order for inbound interceptors
        String[] handlerNames = {"soapHandler4", "soapHandler3", "handler2", "handler1", "servant",
                                 "handler1", "handler2", "soapHandler3", "soapHandler4"};

        List<String> resp = getHandlerNames(inMsg.getSOAPBody());
        assertEquals(handlerNames.length, resp.size());

        Iterator iter = resp.iterator();
        for (String expected : handlerNames) {
            assertEquals(expected, iter.next());
View Full Code Here

            return;
        }
        message.put(BODY_FILLED_IN, Boolean.TRUE);

        try {
            SOAPMessage soapMessage = message.getContent(SOAPMessage.class);
            if (soapMessage == null) {
                MessageFactory factory = preInterceptor.getFactory(message);
                soapMessage = factory.createMessage();
                message.setContent(SOAPMessage.class, soapMessage);
            }
            XMLStreamReader xmlReader = message.getContent(XMLStreamReader.class);
            if (xmlReader == null) {
                return;
            }
            final SOAPPart part = soapMessage.getSOAPPart();
            Document node = (Document) message.getContent(Node.class);
            if (node != part && node != null) {
                StaxUtils.copy(node, new SAAJStreamWriter(part));
            }
            message.setContent(Node.class, soapMessage.getSOAPPart());

            Collection<Attachment> atts = message.getAttachments();
            if (atts != null) {
                for (Attachment a : atts) {
                    if (a.getDataHandler().getDataSource() instanceof AttachmentDataSource) {
                        try {
                            ((AttachmentDataSource)a.getDataHandler().getDataSource()).cache(message);
                        } catch (IOException e) {
                            throw new Fault(e);
                        }
                    }
                    AttachmentPart ap = soapMessage.createAttachmentPart(a.getDataHandler());
                    Iterator<String> i = a.getHeaderNames();
                    while (i != null && i.hasNext()) {
                        String h = i.next();
                        String val = a.getHeader(h);
                        ap.addMimeHeader(h, val);
                    }
                    if (StringUtils.isEmpty(ap.getContentId())) {
                        ap.setContentId(a.getId());
                    }
                    soapMessage.addAttachmentPart(ap);
                }
            }
           
            //replace header element if necessary
            if (message.hasHeaders()) {
                replaceHeaders(soapMessage, message);
            }

            if (soapMessage.getSOAPPart().getEnvelope().getHeader() == null) {
                soapMessage.getSOAPPart().getEnvelope().addHeader();
            }
           
            StaxUtils.copy(xmlReader,
                           new SAAJStreamWriter(soapMessage.getSOAPPart(),
                                                soapMessage.getSOAPPart().getEnvelope().getBody()),
                           true, true);
            DOMSource bodySource = new DOMSource(soapMessage.getSOAPPart().getEnvelope().getBody());
            xmlReader = StaxUtils.createXMLStreamReader(bodySource);
            xmlReader.nextTag();
            xmlReader.nextTag(); // move past body tag
            message.setContent(XMLStreamReader.class, xmlReader);          
        } catch (SOAPException soape) {
View Full Code Here

TOP

Related Classes of javax.xml.soap.SOAPMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.