Java Code Examples for javax.xml.soap.SOAPMessage#getMimeHeaders()

The following examples show how to use javax.xml.soap.SOAPMessage#getMimeHeaders() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SOAPProviderArgumentBuilder.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected Packet getResponse(Packet request, @Nullable SOAPMessage returnValue, WSDLPort port, WSBinding binding) {
    Packet response = super.getResponse(request, returnValue, port, binding);
    // Populate SOAPMessage's transport headers
    if (returnValue != null && response.supports(Packet.OUTBOUND_TRANSPORT_HEADERS)) {
        MimeHeaders hdrs = returnValue.getMimeHeaders();
        Map<String, List<String>> headers = new HashMap<String, List<String>>();
        Iterator i = hdrs.getAllHeaders();
        while(i.hasNext()) {
            MimeHeader header = (MimeHeader)i.next();
            if(header.getName().equalsIgnoreCase("SOAPAction"))
                // SAAJ sets this header automatically, but it interferes with the correct operation of JAX-WS.
                // so ignore this header.
                continue;

            List<String> list = headers.get(header.getName());
            if (list == null) {
                list = new ArrayList<String>();
                headers.put(header.getName(), list);
            }
            list.add(header.getValue());
        }
        response.put(Packet.OUTBOUND_TRANSPORT_HEADERS, headers);
    }
    return response;
}
 
Example 2
Source File: SoapRequestBean.java    From openxds with Apache License 2.0 6 votes vote down vote up
private static void printMessage(SOAPMessage message, String headerType) throws IOException, SOAPException {
    if (message != null) {
        //get the mime headers and print them
        System.out.println("\n\nHeader: " + headerType);
        if (message.saveRequired()) {
            message.saveChanges();
        }
        MimeHeaders headers = message.getMimeHeaders();
        printHeaders(headers);
        
        //print the message itself
        System.out.println("\n\nMessage: " + headerType);
        message.writeTo(System.out);
        System.out.println();
    }
}
 
Example 3
Source File: SOAPProviderArgumentBuilder.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected Packet getResponse(Packet request, @Nullable SOAPMessage returnValue, WSDLPort port, WSBinding binding) {
    Packet response = super.getResponse(request, returnValue, port, binding);
    // Populate SOAPMessage's transport headers
    if (returnValue != null && response.supports(Packet.OUTBOUND_TRANSPORT_HEADERS)) {
        MimeHeaders hdrs = returnValue.getMimeHeaders();
        Map<String, List<String>> headers = new HashMap<String, List<String>>();
        Iterator i = hdrs.getAllHeaders();
        while(i.hasNext()) {
            MimeHeader header = (MimeHeader)i.next();
            if(header.getName().equalsIgnoreCase("SOAPAction"))
                // SAAJ sets this header automatically, but it interferes with the correct operation of JAX-WS.
                // so ignore this header.
                continue;

            List<String> list = headers.get(header.getName());
            if (list == null) {
                list = new ArrayList<String>();
                headers.put(header.getName(), list);
            }
            list.add(header.getValue());
        }
        response.put(Packet.OUTBOUND_TRANSPORT_HEADERS, headers);
    }
    return response;
}
 
Example 4
Source File: SOAPProviderArgumentBuilder.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected Packet getResponse(Packet request, @Nullable SOAPMessage returnValue, WSDLPort port, WSBinding binding) {
    Packet response = super.getResponse(request, returnValue, port, binding);
    // Populate SOAPMessage's transport headers
    if (returnValue != null && response.supports(Packet.OUTBOUND_TRANSPORT_HEADERS)) {
        MimeHeaders hdrs = returnValue.getMimeHeaders();
        Map<String, List<String>> headers = new HashMap<String, List<String>>();
        Iterator i = hdrs.getAllHeaders();
        while(i.hasNext()) {
            MimeHeader header = (MimeHeader)i.next();
            if(header.getName().equalsIgnoreCase("SOAPAction"))
                // SAAJ sets this header automatically, but it interferes with the correct operation of JAX-WS.
                // so ignore this header.
                continue;

            List<String> list = headers.get(header.getName());
            if (list == null) {
                list = new ArrayList<String>();
                headers.put(header.getName(), list);
            }
            list.add(header.getValue());
        }
        response.put(Packet.OUTBOUND_TRANSPORT_HEADERS, headers);
    }
    return response;
}
 
Example 5
Source File: SOAPProviderArgumentBuilder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected Packet getResponse(Packet request, @Nullable SOAPMessage returnValue, WSDLPort port, WSBinding binding) {
    Packet response = super.getResponse(request, returnValue, port, binding);
    // Populate SOAPMessage's transport headers
    if (returnValue != null && response.supports(Packet.OUTBOUND_TRANSPORT_HEADERS)) {
        MimeHeaders hdrs = returnValue.getMimeHeaders();
        Map<String, List<String>> headers = new HashMap<String, List<String>>();
        Iterator i = hdrs.getAllHeaders();
        while(i.hasNext()) {
            MimeHeader header = (MimeHeader)i.next();
            if(header.getName().equalsIgnoreCase("SOAPAction"))
                // SAAJ sets this header automatically, but it interferes with the correct operation of JAX-WS.
                // so ignore this header.
                continue;

            List<String> list = headers.get(header.getName());
            if (list == null) {
                list = new ArrayList<String>();
                headers.put(header.getName(), list);
            }
            list.add(header.getValue());
        }
        response.put(Packet.OUTBOUND_TRANSPORT_HEADERS, headers);
    }
    return response;
}
 
Example 6
Source File: SOAPProviderArgumentBuilder.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected Packet getResponse(Packet request, @Nullable SOAPMessage returnValue, WSDLPort port, WSBinding binding) {
    Packet response = super.getResponse(request, returnValue, port, binding);
    // Populate SOAPMessage's transport headers
    if (returnValue != null && response.supports(Packet.OUTBOUND_TRANSPORT_HEADERS)) {
        MimeHeaders hdrs = returnValue.getMimeHeaders();
        Map<String, List<String>> headers = new HashMap<String, List<String>>();
        Iterator i = hdrs.getAllHeaders();
        while(i.hasNext()) {
            MimeHeader header = (MimeHeader)i.next();
            if(header.getName().equalsIgnoreCase("SOAPAction"))
                // SAAJ sets this header automatically, but it interferes with the correct operation of JAX-WS.
                // so ignore this header.
                continue;

            List<String> list = headers.get(header.getName());
            if (list == null) {
                list = new ArrayList<String>();
                headers.put(header.getName(), list);
            }
            list.add(header.getValue());
        }
        response.put(Packet.OUTBOUND_TRANSPORT_HEADERS, headers);
    }
    return response;
}
 
Example 7
Source File: SOAPProviderArgumentBuilder.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected Packet getResponse(Packet request, @Nullable SOAPMessage returnValue, WSDLPort port, WSBinding binding) {
    Packet response = super.getResponse(request, returnValue, port, binding);
    // Populate SOAPMessage's transport headers
    if (returnValue != null && response.supports(Packet.OUTBOUND_TRANSPORT_HEADERS)) {
        MimeHeaders hdrs = returnValue.getMimeHeaders();
        Map<String, List<String>> headers = new HashMap<String, List<String>>();
        Iterator i = hdrs.getAllHeaders();
        while(i.hasNext()) {
            MimeHeader header = (MimeHeader)i.next();
            if(header.getName().equalsIgnoreCase("SOAPAction"))
                // SAAJ sets this header automatically, but it interferes with the correct operation of JAX-WS.
                // so ignore this header.
                continue;

            List<String> list = headers.get(header.getName());
            if (list == null) {
                list = new ArrayList<String>();
                headers.put(header.getName(), list);
            }
            list.add(header.getValue());
        }
        response.put(Packet.OUTBOUND_TRANSPORT_HEADERS, headers);
    }
    return response;
}
 
Example 8
Source File: SOAPProviderArgumentBuilder.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected Packet getResponse(Packet request, @Nullable SOAPMessage returnValue, WSDLPort port, WSBinding binding) {
    Packet response = super.getResponse(request, returnValue, port, binding);
    // Populate SOAPMessage's transport headers
    if (returnValue != null && response.supports(Packet.OUTBOUND_TRANSPORT_HEADERS)) {
        MimeHeaders hdrs = returnValue.getMimeHeaders();
        Map<String, List<String>> headers = new HashMap<String, List<String>>();
        Iterator i = hdrs.getAllHeaders();
        while(i.hasNext()) {
            MimeHeader header = (MimeHeader)i.next();
            if(header.getName().equalsIgnoreCase("SOAPAction"))
                // SAAJ sets this header automatically, but it interferes with the correct operation of JAX-WS.
                // so ignore this header.
                continue;

            List<String> list = headers.get(header.getName());
            if (list == null) {
                list = new ArrayList<String>();
                headers.put(header.getName(), list);
            }
            list.add(header.getValue());
        }
        response.put(Packet.OUTBOUND_TRANSPORT_HEADERS, headers);
    }
    return response;
}
 
Example 9
Source File: SOAPProviderArgumentBuilder.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected Packet getResponse(Packet request, @Nullable SOAPMessage returnValue, WSDLPort port, WSBinding binding) {
    Packet response = super.getResponse(request, returnValue, port, binding);
    // Populate SOAPMessage's transport headers
    if (returnValue != null && response.supports(Packet.OUTBOUND_TRANSPORT_HEADERS)) {
        MimeHeaders hdrs = returnValue.getMimeHeaders();
        Map<String, List<String>> headers = new HashMap<String, List<String>>();
        Iterator i = hdrs.getAllHeaders();
        while(i.hasNext()) {
            MimeHeader header = (MimeHeader)i.next();
            if(header.getName().equalsIgnoreCase("SOAPAction"))
                // SAAJ sets this header automatically, but it interferes with the correct operation of JAX-WS.
                // so ignore this header.
                continue;

            List<String> list = headers.get(header.getName());
            if (list == null) {
                list = new ArrayList<String>();
                headers.put(header.getName(), list);
            }
            list.add(header.getValue());
        }
        response.put(Packet.OUTBOUND_TRANSPORT_HEADERS, headers);
    }
    return response;
}
 
Example 10
Source File: HarFileHandler.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public boolean handleInbound(SOAPMessageContext context) {
   this.setHandler();
   SOAPMessage msg = context.getMessage();

   try {
      String soapenv = this.getEnvelope(msg);
      JsonObject response = new JsonObject();
      response.addProperty("status", 200);
      response.addProperty("statusText", "OK");
      response.addProperty("httpVersion", "HTTP/1.1");
      response.add("headers", this.handleHeaders(msg.getMimeHeaders()));
      response.add("cookies", new JsonArray());
      JsonObject content = new JsonObject();
      content.addProperty("size", soapenv.getBytes().length);
      response.addProperty("headersSize", -1);
      response.addProperty("bodySize", -1);
      response.addProperty("redirectURL", "");
      content.addProperty("mimeType", "text/xml; charset=utf-8");
      if (msg.getMimeHeaders() != null) {
         String[] header = msg.getMimeHeaders().getHeader("Content-Type");
         if (header != null && header.length > 0) {
            content.addProperty("mimeType", header[0]);
         }
      }

      content.addProperty("text", soapenv);
      response.add("content", content);
      this.getEntry().add("response", response);
      this.getEntry().get("timings").getAsJsonObject().addProperty("wait", this.recieved - this.split);
      long end = System.currentTimeMillis();
      this.getEntry().get("timings").getAsJsonObject().addProperty("receive", end - this.recieved);
      this.getEntry().addProperty("time", end - this.start);
      this.saveHar();
   } catch (Exception var8) {
      LOG.error(var8.getMessage(), var8);
   }

   return true;
}
 
Example 11
Source File: CougarHelpers.java    From cougar with Apache License 2.0 5 votes vote down vote up
private void extractHeaderDataSOAP(SOAPMessage response, HttpResponseBean responseBean) throws SOAPException
{
	//extract MimeHeaders
	MimeHeaders mime = response.getMimeHeaders();
	Iterator<MimeHeader> iter = mime.getAllHeaders();

	while(iter.hasNext())
	{
		MimeHeader mimeH = iter.next();
		responseBean.addEntryToResponseHeaders(mimeH.getName(),mimeH.getValue());

	}

	//extract SOAPHeaders from the envelope and a them to the mimeHeaders
	if(response.getSOAPHeader()!=null)
	{
		javax.xml.soap.SOAPHeader header = response.getSOAPHeader();

		NodeList nodes = header.getChildNodes();


		for(int x=0; x<nodes.getLength();x++)
		{
			//if the header entry contains child nodes - write them with the node names
			if(nodes.item(x).hasChildNodes()){
				NodeList childnodes = nodes.item(x).getChildNodes();
				for(int y = 0; y<childnodes.getLength();y++){
                       responseBean.addEntryToResponseHeaders(nodes.item(x).getLocalName(),childnodes.item(y).getLocalName()+":"+childnodes.item(y).getTextContent());
                   }
			}
			else{
				responseBean.addEntryToResponseHeaders(nodes.item(x).getLocalName(), nodes.item(x).getTextContent());
			}
		}
	}
}
 
Example 12
Source File: AbstractITEndpoint.java    From spring-ws-security-soap-example with MIT License 5 votes vote down vote up
/**
 * Calls the web service being tested and returns the response.
 *
 * @param request
 *            request to the web service
 * @return the web service response
 * @throws SOAPException
 *             never, this is a required declaration
 */
protected final SOAPMessage callWebService(final SOAPMessage request)
        throws SOAPException {
    final SOAPConnectionFactory soapConnectionFactory; // Connection factory
    final MimeHeaders headers; // Message headers

    soapConnectionFactory = SOAPConnectionFactory.newInstance();

    // Sets the SOAP action
    headers = request.getMimeHeaders();
    headers.addHeader("SOAPAction", soapAction);
    request.saveChanges();

    return soapConnectionFactory.createConnection().call(request, wsURL);
}
 
Example 13
Source File: SOAPConnectionImpl.java    From JVoiceXML with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Checks whether the request has an associated SOAPAction MIME header
 * and returns its value.
 * @param request the message to check
 * @return the value of any associated SOAPAction MIME header or null
 * if there is no such header.
 */
private String checkForSOAPActionHeader(SOAPMessage request) {
    MimeHeaders hdrs = request.getMimeHeaders();
    if (hdrs != null) {
        String[] saHdrs = hdrs.getHeader("SOAPAction");
        if (saHdrs != null && saHdrs.length > 0)
            return saHdrs[0];
    }
    return null;
}
 
Example 14
Source File: SoapRequestBean.java    From openxds with Apache License 2.0 5 votes vote down vote up
private ByteArrayOutputStream printWebMessage(SOAPMessage message, String headerType, ByteArrayOutputStream bye) throws IOException, SOAPException {
    
    PrintStream printStream = new PrintStream(bye);
    bye.reset();
    
    printStream.println("\n************************************************");
    if (message != null) {
        //get the mime headers and print them
        printStream.println("\n\nHeader: " + headerType);
        if (message.saveRequired()) {
            message.saveChanges();
        }
        MimeHeaders headers = message.getMimeHeaders();
        Iterator iter = headers.getAllHeaders();
        while (iter.hasNext()) {
            MimeHeader header = (MimeHeader)iter.next();
            System.out.println("the header is " + header.getValue());
            printStream.println("\t" + header.getName() + " : " + header.getValue());
        }
        
        //print the message itself
        
        printStream.println("\n\nMessage: " + headerType);
        message.writeTo(bye);
    }
    return bye;
}
 
Example 15
Source File: HarFileHandler.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public boolean handleInbound(SOAPMessageContext context) {
   this.setHandler();
   SOAPMessage msg = context.getMessage();

   try {
      String soapenv = this.getEnvelope(msg);
      JsonObject response = new JsonObject();
      response.addProperty("status", 200);
      response.addProperty("statusText", "OK");
      response.addProperty("httpVersion", "HTTP/1.1");
      response.add("headers", this.handleHeaders(msg.getMimeHeaders()));
      response.add("cookies", new JsonArray());
      JsonObject content = new JsonObject();
      content.addProperty("size", soapenv.getBytes().length);
      response.addProperty("headersSize", -1);
      response.addProperty("bodySize", -1);
      response.addProperty("redirectURL", "");
      content.addProperty("mimeType", "text/xml; charset=utf-8");
      if (msg.getMimeHeaders() != null) {
         String[] header = msg.getMimeHeaders().getHeader("Content-Type");
         if (header != null && header.length > 0) {
            content.addProperty("mimeType", header[0]);
         }
      }

      content.addProperty("text", soapenv);
      response.add("content", content);
      this.getEntry().add("response", response);
      this.getEntry().get("timings").getAsJsonObject().addProperty("wait", this.recieved - this.split);
      long end = System.currentTimeMillis();
      this.getEntry().get("timings").getAsJsonObject().addProperty("receive", end - this.recieved);
      this.getEntry().addProperty("time", end - this.start);
      this.saveHar();
   } catch (Exception var8) {
      LOG.error(var8.getMessage(), var8);
   }

   return true;
}
 
Example 16
Source File: HarFileHandler.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public boolean handleInbound(SOAPMessageContext context) {
   this.setHandler();
   SOAPMessage msg = context.getMessage();

   try {
      String soapenv = this.getEnvelope(msg);
      JsonObject response = new JsonObject();
      response.addProperty("status", Integer.valueOf(200));
      response.addProperty("statusText", "OK");
      response.addProperty("httpVersion", "HTTP/1.1");
      response.add("headers", this.handleHeaders(msg.getMimeHeaders()));
      response.add("cookies", new JsonArray());
      JsonObject content = new JsonObject();
      content.addProperty("size", soapenv.getBytes().length);
      response.addProperty("headersSize", Integer.valueOf(-1));
      response.addProperty("bodySize", Integer.valueOf(-1));
      response.addProperty("redirectURL", "");
      content.addProperty("mimeType", "text/xml; charset=utf-8");
      if (msg.getMimeHeaders() != null) {
         String[] header = msg.getMimeHeaders().getHeader("Content-Type");
         if (header != null && header.length > 0) {
            content.addProperty("mimeType", header[0]);
         }
      }

      content.addProperty("text", soapenv);
      response.add("content", content);
      this.getEntry().add("response", response);
      this.getEntry().get("timings").getAsJsonObject().addProperty("wait", this.recieved.longValue() - this.split.longValue());
      long end = System.currentTimeMillis();
      this.getEntry().get("timings").getAsJsonObject().addProperty("receive", end - this.recieved.longValue());
      this.getEntry().addProperty("time", end - this.start.longValue());
      this.saveHar();
   } catch (Exception var8) {
      LOG.error(var8.getMessage(), var8);
   }

   return true;
}
 
Example 17
Source File: HarFileHandler.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public boolean handleInbound(SOAPMessageContext context) {
   this.setHandler();
   SOAPMessage msg = context.getMessage();

   try {
      String soapenv = this.getEnvelope(msg);
      JsonObject response = new JsonObject();
      response.addProperty("status", Integer.valueOf(200));
      response.addProperty("statusText", "OK");
      response.addProperty("httpVersion", "HTTP/1.1");
      response.add("headers", this.handleHeaders(msg.getMimeHeaders()));
      response.add("cookies", new JsonArray());
      JsonObject content = new JsonObject();
      content.addProperty("size", soapenv.getBytes().length);
      response.addProperty("headersSize", Integer.valueOf(-1));
      response.addProperty("bodySize", Integer.valueOf(-1));
      response.addProperty("redirectURL", "");
      content.addProperty("mimeType", "text/xml; charset=utf-8");
      if (msg.getMimeHeaders() != null) {
         String[] header = msg.getMimeHeaders().getHeader("Content-Type");
         if (header != null && header.length > 0) {
            content.addProperty("mimeType", header[0]);
         }
      }

      content.addProperty("text", soapenv);
      response.add("content", content);
      this.getEntry().add("response", response);
      this.getEntry().get("timings").getAsJsonObject().addProperty("wait", this.recieved.longValue() - this.split.longValue());
      long end = System.currentTimeMillis();
      this.getEntry().get("timings").getAsJsonObject().addProperty("receive", end - this.recieved.longValue());
      this.getEntry().addProperty("time", end - this.start.longValue());
      this.saveHar();
   } catch (Exception var8) {
      LOG.error(var8.getMessage(), var8);
   }

   return true;
}
 
Example 18
Source File: HarFileHandler.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public boolean handleInbound(SOAPMessageContext context) {
   this.setHandler();
   SOAPMessage msg = context.getMessage();

   try {
      String soapenv = this.getEnvelope(msg);
      JsonObject response = new JsonObject();
      response.addProperty("status", 200);
      response.addProperty("statusText", "OK");
      response.addProperty("httpVersion", "HTTP/1.1");
      response.add("headers", this.handleHeaders(msg.getMimeHeaders()));
      response.add("cookies", new JsonArray());
      JsonObject content = new JsonObject();
      content.addProperty("size", soapenv.getBytes().length);
      response.addProperty("headersSize", -1);
      response.addProperty("bodySize", -1);
      response.addProperty("redirectURL", "");
      content.addProperty("mimeType", "text/xml; charset=utf-8");
      if (msg.getMimeHeaders() != null) {
         String[] header = msg.getMimeHeaders().getHeader("Content-Type");
         if (header != null && header.length > 0) {
            content.addProperty("mimeType", header[0]);
         }
      }

      content.addProperty("text", soapenv);
      response.add("content", content);
      this.getEntry().add("response", response);
      this.getEntry().get("timings").getAsJsonObject().addProperty("wait", this.recieved - this.split);
      long end = System.currentTimeMillis();
      this.getEntry().get("timings").getAsJsonObject().addProperty("receive", end - this.recieved);
      this.getEntry().addProperty("time", end - this.start);
      this.saveHar();
   } catch (Exception var8) {
      LOG.error(var8.getMessage(), var8);
   }

   return true;
}
 
Example 19
Source File: JRXmlaQueryExecuter.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected SOAPMessage createQueryMessage()
{
	String queryStr = getQueryString();

	if (log.isDebugEnabled())
	{
		log.debug("MDX query: " + queryStr);
	}
	
	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<String, String> paraList = new HashMap<String, String>();
		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: \n" + prettyPrintSOAP(message.getSOAPPart().getEnvelope()));
		}

		return message;
	}
	catch (SOAPException e)
	{
		throw new JRRuntimeException(e);
	}
}
 
Example 20
Source File: SOAPRequestBuilder.java    From cougar with Apache License 2.0 4 votes vote down vote up
public SOAPMessage buildSOAPRequest(Document document,
		HttpCallBean httpCallBean) {

	nameSpace = httpCallBean.getNameSpace();

	if (nameSpace == null || nameSpace.equals("")) {
		throw new RuntimeException(
				"Cannot create SOAP message using the following name space : "
						+ nameSpace);
	}

	// Construct SOAPMessage
	MessageFactory mf;
	try {
		mf = MessageFactory.newInstance();

		SOAPMessage message = mf.createMessage();
		
		//add headers here
		
		MimeHeaders hd = message.getMimeHeaders();
		hd.addHeader("X-Forwarded-For", httpCallBean.getIpAddress());
		
		//SCR: 103 Trace Me testing
		//hd.addHeader("X-Trace-Me", "true");
		
		//
		if(httpCallBean.getHeaderParams()!=null)
		{
		for (String key: httpCallBean.getHeaderParams().keySet())
		{
			hd.addHeader(key, httpCallBean.getHeaderParams().get(key));
		}
		}

		SOAPPart soapPart = message.getSOAPPart();
		SOAPEnvelope envelope = soapPart.getEnvelope();

		envelope.addNamespaceDeclaration("bas", nameSpace);

		// generate header
		generateSoapHeader(envelope, httpCallBean);

		// generate body
		generateSOAPBody(envelope, document);

		message.saveChanges();

		// TODO write this to the logs
		
		//Uncomment for debug

		/*try
		{
		System.out.println("\n Soap Request:\n");
		message.writeTo(System.out);
		System.out.println();
		}
		catch (IOException e) {
			throw new UtilityException(e);
		}*/
		

		return message;

	} catch (SOAPException e) {
		throw new RuntimeException(e);
	} 
}