List of usage examples for javax.xml.soap SOAPMessage getSOAPBody
public SOAPBody getSOAPBody() throws SOAPException
From source file:Main.java
public static void main(String[] args) throws Exception { SOAPConnectionFactory sfc = SOAPConnectionFactory.newInstance(); SOAPConnection connection = sfc.createConnection(); MessageFactory mf = MessageFactory.newInstance(); SOAPMessage sm = mf.createMessage(); QName bodyName = new QName("http://YourSOAPServer.com", "GetQuote", "d"); URL endpoint = new URL("http://YourSOAPServer.com"); SOAPMessage response = connection.call(sm, endpoint); SOAPBody sb = response.getSOAPBody(); java.util.Iterator iterator = sb.getChildElements(bodyName); while (iterator.hasNext()) { SOAPBodyElement bodyElement = (SOAPBodyElement) iterator.next(); String val = bodyElement.getValue(); System.out.println("The Value is:" + val); }//from w ww . j a va 2 s . com }
From source file:SOAPResponse.java
public static void main(String[] args) { try {/* ww w . j av a2 s. c om*/ SOAPConnectionFactory sfc = SOAPConnectionFactory.newInstance(); SOAPConnection connection = sfc.createConnection(); MessageFactory mf = MessageFactory.newInstance(); SOAPMessage sm = mf.createMessage(); QName bodyName = new QName("http://YourSOAPServer.com", "GetQuote", "d"); URL endpoint = new URL("http://YourSOAPServer.com"); SOAPMessage response = connection.call(sm, endpoint); SOAPBody sb = response.getSOAPBody(); java.util.Iterator iterator = sb.getChildElements(bodyName); while (iterator.hasNext()) { SOAPBodyElement bodyElement = (SOAPBodyElement) iterator.next(); String val = bodyElement.getValue(); System.out.println("The Value is:" + val); } } catch (Exception ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) throws Exception { SOAPConnectionFactory sfc = SOAPConnectionFactory.newInstance(); SOAPConnection connection = sfc.createConnection(); MessageFactory mf = MessageFactory.newInstance(); SOAPMessage sm = mf.createMessage(); SOAPHeader sh = sm.getSOAPHeader(); SOAPBody sb = sm.getSOAPBody(); sh.detachNode();//from w w w .jav a2s . co m QName bodyName = new QName("http://quoteCompany.com", "GetQuote", "d"); SOAPBodyElement bodyElement = sb.addBodyElement(bodyName); QName qn = new QName("aName"); SOAPElement quotation = bodyElement.addChildElement(qn); quotation.addTextNode("TextMode"); System.out.println("\n Soap Request:\n"); sm.writeTo(System.out); System.out.println(); URL endpoint = new URL("http://yourServer.com"); SOAPMessage response = connection.call(sm, endpoint); System.out.println(response.getContentDescription()); }
From source file:SOAPRequest.java
public static void main(String[] args) { try {/*from www .j a va2 s. c o m*/ SOAPConnectionFactory sfc = SOAPConnectionFactory.newInstance(); SOAPConnection connection = sfc.createConnection(); MessageFactory mf = MessageFactory.newInstance(); SOAPMessage sm = mf.createMessage(); SOAPHeader sh = sm.getSOAPHeader(); SOAPBody sb = sm.getSOAPBody(); sh.detachNode(); QName bodyName = new QName("http://quoteCompany.com", "GetQuote", "d"); SOAPBodyElement bodyElement = sb.addBodyElement(bodyName); QName qn = new QName("aName"); SOAPElement quotation = bodyElement.addChildElement(qn); quotation.addTextNode("TextMode"); System.out.println("\n Soap Request:\n"); sm.writeTo(System.out); System.out.println(); URL endpoint = new URL("http://yourServer.com"); SOAPMessage response = connection.call(sm, endpoint); System.out.println(response.getContentDescription()); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:net.bpelunit.framework.control.util.BPELUnitUtil.java
/** * Creates a new, generic SOAP fault to be used when something goes wrong in a partner track and * other tracks must be notified.//from w ww. ja v a 2s . c om * * @return */ public static SOAPMessage generateGenericSOAPFault() { try { MessageFactory mFactory = MessageFactory.newInstance(); SOAPMessage message = mFactory.createMessage(); SOAPBody body = message.getSOAPBody(); SOAPFault fault = body.addFault(BPELUnitConstants.SOAP_FAULT_CODE_CLIENT, BPELUnitConstants.SOAP_FAULT_DESCRIPTION); Detail detail = fault.addDetail(); DetailEntry entry = detail .addDetailEntry(new QName("http://www.bpelunit.org/framework/error", "BPELUnitFault")); entry.addTextNode( "The BPELUnit test framework has detected a test failure or error. This test case is aborted."); return message; } catch (Exception e) { return null; } }
From source file:Main.java
public static Document documentFromSoapBody(SOAPMessage soapMessage) throws ParserConfigurationException, SOAPException { SOAPEnvelope env = soapMessage.getSOAPPart().getEnvelope(); SOAPBodyElement body = (SOAPBodyElement) soapMessage.getSOAPBody().getChildNodes().item(0); return documentFromSoapBody(body, getNamespaceDeclarations(env, body)); }
From source file:com.hiperium.commons.client.soap.AthenticationDispatcherTest.java
/** * //from www . j av a 2 s. c o m * @param response */ public static void readSOAPMessageResponse(SOAPMessage response) { SOAPBody authBodyResponse; try { authBodyResponse = response.getSOAPBody(); Node authNode = authBodyResponse.getFirstChild(); NodeList authNodeList = authNode.getChildNodes(); String responseString = authNodeList.item(0).getFirstChild().getNodeValue(); LOGGER.debug("RESPONSE: " + responseString); } catch (SOAPException e) { LOGGER.error(e.getMessage(), e); } }
From source file:Main.java
public static Document documentFromSoapBody(SOAPMessage soapMessage, QName bodyName) throws ParserConfigurationException, SOAPException { SOAPEnvelope env = soapMessage.getSOAPPart().getEnvelope(); SOAPBodyElement body = (SOAPBodyElement) soapMessage.getSOAPBody().getChildElements(bodyName).next(); return documentFromSoapBody(body, getNamespaceDeclarations(env, body)); }
From source file:ee.ria.xroad.proxy.serverproxy.MetadataServiceHandlerImpl.java
private static SoapMessageImpl createMethodListResponse(SoapMessageImpl requestMessage, final JAXBElement<MethodListType> methodList) throws Exception { SoapMessageImpl responseMessage = SoapUtils.toResponse(requestMessage, new SOAPCallback() { @Override//w ww . j a va 2 s . c o m public void call(SOAPMessage soap) throws Exception { soap.getSOAPBody().removeContents(); marshal(methodList, soap.getSOAPBody()); } }); return responseMessage; }
From source file:com.wandrell.example.swss.test.util.SoapMessageUtils.java
/** * Creates an {@code Entity} from the received {@code SOAPMessage}. * <p>//from w w w .ja va2 s.c om * The message should be valid and contain a {@code GetEntityResponse}. * * @param message * the SOAP message * @return an {@code Entity} parsed from the {@code SOAPMessage} * @throws JAXBException * if there is any problem when unmarshalling the data * @throws SOAPException * if there is any problem when reading the SOAP message */ public static final Entity getEntity(final SOAPMessage message) throws JAXBException, SOAPException { final JAXBContext jc; // Context for unmarshalling final Unmarshaller um; // Unmarshaller for the SOAP message final GetEntityResponse response; // Unmarshalled response jc = JAXBContext.newInstance(GetEntityResponse.class); um = jc.createUnmarshaller(); response = (GetEntityResponse) um.unmarshal(message.getSOAPBody().extractContentAsDocument()); return response.getEntity(); }