List of usage examples for javax.xml.soap SOAPBody addChildElement
public SOAPElement addChildElement(String localName, String prefix) throws SOAPException;
From source file:au.com.ors.rest.controller.AutoCheckController.java
private SOAPMessage createSOAPRequest(String driverLicenseNumber, String fullName, String postCode) throws Exception { MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage soapMessage = messageFactory.createMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); String serverURI = "http://soap.ors.com.au/pdv"; SOAPEnvelope envelope = soapPart.getEnvelope(); envelope.addNamespaceDeclaration("pdv", serverURI); SOAPBody soapBody = envelope.getBody(); SOAPElement soapElement = soapBody.addChildElement("PDVCheckRequestMsg", "pdv"); SOAPElement soapElementChild1 = soapElement.addChildElement("driverLicenseNumber", "pdv"); soapElementChild1.addTextNode(driverLicenseNumber); SOAPElement soapElementChild2 = soapElement.addChildElement("fullName", "pdv"); soapElementChild2.addTextNode(fullName); SOAPElement soapElementChild3 = soapElement.addChildElement("postCode", "pdv"); soapElementChild3.addTextNode(postCode); // MimeHeaders headers = soapMessage.getMimeHeaders(); // headers.addHeader(S, value); soapMessage.saveChanges();/*from w ww. ja va2s . c o m*/ System.out.println("Request SOAP Message:"); soapMessage.writeTo(System.out); return soapMessage; }
From source file:com.polivoto.networking.SoapClient.java
private SOAPMessage createSOAPRequest() throws SOAPException, IOException { MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage soapMessage = messageFactory.createMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); String serverURI = "http://votingservice.develops.capiz.org"; // SOAP Envelope SOAPEnvelope envelope = soapPart.getEnvelope(); envelope.addNamespaceDeclaration("example", serverURI); /* El siguiente es un ejemplo tomado de donde me bas para armar la solicitud. Constructed SOAP Request Message:// w w w . ja v a 2 s.c o m <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:example="http://ws.cdyne.com/"> <SOAP-ENV:Header/> <SOAP-ENV:Body> <example:VerifyEmail> <example:email>mutantninja@gmail.com</example:email> <example:LicenseKey>123</example:LicenseKey> </example:VerifyEmail> </SOAP-ENV:Body> </SOAP-ENV:Envelope> */ // SOAP Body SOAPBody soapBody = envelope.getBody(); SOAPElement soapBodyElem = soapBody.addChildElement("serviceChooser", "example"); SOAPElement soapBodyElem1 = soapBodyElem.addChildElement("json", "example"); soapBodyElem1.addTextNode(json.toString()); MimeHeaders headers = soapMessage.getMimeHeaders(); headers.addHeader("SOAPAction", serverURI + "serviceChooser"); soapMessage.saveChanges(); return soapMessage; }
From source file:edu.unc.lib.dl.services.TripleStoreManagerMulgaraImpl.java
private String sendTQL(String query) { log.info(query);//from w w w . j a va 2s. co m String result = null; try { // First create the connection SOAPConnectionFactory soapConnFactory = SOAPConnectionFactory.newInstance(); SOAPConnection connection = soapConnFactory.createConnection(); // Next, create the actual message MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage message = messageFactory.createMessage(); message.getMimeHeaders().setHeader("SOAPAction", "itqlbean:executeQueryToString"); SOAPBody soapBody = message.getSOAPPart().getEnvelope().getBody(); soapBody.addNamespaceDeclaration("xsd", JDOMNamespaceUtil.XSD_NS.getURI()); soapBody.addNamespaceDeclaration("xsi", JDOMNamespaceUtil.XSI_NS.getURI()); soapBody.addNamespaceDeclaration("itqlbean", this.getItqlEndpointURL()); SOAPElement eqts = soapBody.addChildElement("executeQueryToString", "itqlbean"); SOAPElement queryStr = eqts.addChildElement("queryString", "itqlbean"); queryStr.setAttributeNS(JDOMNamespaceUtil.XSI_NS.getURI(), "xsi:type", "xsd:string"); CDATASection queryCDATA = message.getSOAPPart().createCDATASection(query); queryStr.appendChild(queryCDATA); message.saveChanges(); SOAPMessage reply = connection.call(message, this.getItqlEndpointURL()); if (reply.getSOAPBody().hasFault()) { reportSOAPFault(reply); if (log.isDebugEnabled()) { // log the full soap body response DOMBuilder builder = new DOMBuilder(); org.jdom.Document jdomDoc = builder.build(reply.getSOAPBody().getOwnerDocument()); log.info(new XMLOutputter().outputString(jdomDoc)); } } else { NodeList nl = reply.getSOAPPart().getEnvelope().getBody().getElementsByTagNameNS("*", "executeQueryToStringReturn"); if (nl.getLength() > 0) { result = nl.item(0).getTextContent(); } log.debug(result); } } catch (SOAPException e) { throw new Error("Cannot query triple store at " + this.getItqlEndpointURL(), e); } return result; }
From source file:edu.unc.lib.dl.util.TripleStoreQueryServiceMulgaraImpl.java
private String sendTQL(String query) { log.debug(query);//from ww w . j a v a 2s . c om String result = null; SOAPMessage reply = null; SOAPConnection connection = null; try { // Next, create the actual message MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage message = messageFactory.createMessage(); message.getMimeHeaders().setHeader("SOAPAction", "itqlbean:executeQueryToString"); SOAPBody soapBody = message.getSOAPPart().getEnvelope().getBody(); soapBody.addNamespaceDeclaration("xsd", JDOMNamespaceUtil.XSD_NS.getURI()); soapBody.addNamespaceDeclaration("xsi", JDOMNamespaceUtil.XSI_NS.getURI()); soapBody.addNamespaceDeclaration("itqlbean", this.getItqlEndpointURL()); SOAPElement eqts = soapBody.addChildElement("executeQueryToString", "itqlbean"); SOAPElement queryStr = eqts.addChildElement("queryString", "itqlbean"); queryStr.setAttributeNS(JDOMNamespaceUtil.XSI_NS.getURI(), "xsi:type", "xsd:string"); CDATASection queryCDATA = message.getSOAPPart().createCDATASection(query); queryStr.appendChild(queryCDATA); message.saveChanges(); // First create the connection SOAPConnectionFactory soapConnFactory = SOAPConnectionFactory.newInstance(); connection = soapConnFactory.createConnection(); reply = connection.call(message, this.getItqlEndpointURL()); if (reply.getSOAPBody().hasFault()) { reportSOAPFault(reply); if (log.isDebugEnabled()) { // log the full soap body response DOMBuilder builder = new DOMBuilder(); org.jdom2.Document jdomDoc = builder.build(reply.getSOAPBody().getOwnerDocument()); log.debug(new XMLOutputter().outputString(jdomDoc)); } } else { NodeList nl = reply.getSOAPPart().getEnvelope().getBody().getElementsByTagNameNS("*", "executeQueryToStringReturn"); if (nl.getLength() > 0) { result = nl.item(0).getFirstChild().getNodeValue(); } log.debug(result); } } catch (SOAPException e) { log.error("Failed to prepare or send iTQL via SOAP", e); throw new RuntimeException("Cannot query triple store at " + this.getItqlEndpointURL(), e); } finally { try { connection.close(); } catch (SOAPException e) { log.error("Failed to close SOAP connection", e); throw new RuntimeException( "Failed to close SOAP connection for triple store at " + this.getItqlEndpointURL(), e); } } return result; }
From source file:org.energy_home.jemma.ah.internal.greenathome.GreenathomeAppliance.java
private static SOAPMessage createSOAPRequest(String date) throws Exception { MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage soapMessage = messageFactory.createMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); String serverURI = "http://ws.i-em.eu/v4/"; // SOAP Envelope SOAPEnvelope envelope = soapPart.getEnvelope(); envelope.addNamespaceDeclaration("example", serverURI); // SOAP Body// w ww.j a v a 2s .c o m SOAPBody soapBody = envelope.getBody(); SOAPElement soapBodyElem = soapBody.addChildElement("Get72hPlantForecast", "example"); SOAPElement soapBodyElem1 = soapBodyElem.addChildElement("plantID", "example"); soapBodyElem1.addTextNode("telecom_02"); SOAPElement soapBodyElem2 = soapBodyElem.addChildElement("quantityID", "example"); soapBodyElem2.addTextNode("frc_pac"); SOAPElement soapBodyElem3 = soapBodyElem.addChildElement("timestamp", "example"); soapBodyElem3.addTextNode(date); SOAPElement soapBodyElem4 = soapBodyElem.addChildElement("langID", "example"); soapBodyElem4.addTextNode("en"); MimeHeaders headers = soapMessage.getMimeHeaders(); headers.addHeader("SOAPAction", serverURI + "Get72hPlantForecast"); soapMessage.saveChanges(); return soapMessage; }
From source file:org.mule.modules.paypal.util.PayPalAPIHelper.java
private static SOAPMessage createGetPalDetailsSOAPRequest(@NotNull String username, @NotNull String password, @NotNull String appId, String signature) throws Exception { MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage soapMessage = messageFactory.createMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); // SOAP Envelope SOAPEnvelope envelope = soapPart.getEnvelope(); envelope.addNamespaceDeclaration(PREFIX_1, SOAP_HEADER_CREDENTIAL_NAMESPACE_1); envelope.addNamespaceDeclaration(PREFIX_2, SOAP_HEADER_CREDENTIAL_NAMESPACE_2); SOAPHeader soapHeader = envelope.getHeader(); if (soapHeader == null) soapHeader = envelope.addHeader(); SOAPElement soapReqElement = soapHeader.addChildElement(rootStringValue, PREFIX_1); SOAPElement soapCredElement = soapReqElement.addChildElement(subRootStringValue, PREFIX_2); soapCredElement.addChildElement(appIdStringValue, PREFIX_2).addTextNode(appId); soapCredElement.addChildElement(usernameStringValue, PREFIX_2).addTextNode(username); soapCredElement.addChildElement(passwordStringValue, PREFIX_2).addTextNode(password); soapCredElement.addChildElement("Signature", PREFIX_2).addTextNode(signature); // SOAP Body/* w w w. j a v a 2s .c o m*/ SOAPBody soapBody = envelope.getBody(); SOAPElement soapBodyElem = soapBody.addChildElement("GetPalDetailsReq", PREFIX_1); SOAPElement soapBodyElem1 = soapBodyElem.addChildElement("GetPalDetailsRequest", PREFIX_1); soapBodyElem1.addChildElement("Version", PREFIX_2).addTextNode("51"); soapMessage.saveChanges(); return soapMessage; }
From source file:org.wso2.carbon.identity.provisioning.connector.InweboUserManager.java
private static SOAPMessage createUserSOAPMessage(Properties inweboProperties, InweboUser user) throws SOAPException { MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage soapMessage = messageFactory.createMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); String serverURI = inweboProperties.getProperty(InweboConnectorConstants.INWEBO_URI); SOAPEnvelope envelope = soapPart.getEnvelope(); String namespacePrefix = InweboConnectorConstants.SOAPMessage.SOAP_NAMESPACE_PREFIX; envelope.addNamespaceDeclaration(namespacePrefix, serverURI); SOAPBody soapBody = envelope.getBody(); SOAPElement soapBodyElem = soapBody .addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_ACTION_LOGIN_CREATE, namespacePrefix); SOAPElement soapBodyElem1 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_USER_ID, namespacePrefix);//from ww w.ja va 2 s .co m soapBodyElem1.addTextNode(user.getUserId()); SOAPElement soapBodyElem2 = soapBodyElem .addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_SERVICE_ID, namespacePrefix); soapBodyElem2.addTextNode(user.getServiceId()); SOAPElement soapBodyElem3 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_LOGIN, namespacePrefix); soapBodyElem3.addTextNode(user.getLogin()); SOAPElement soapBodyElem4 = soapBodyElem .addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_FIRST_NAME, namespacePrefix); soapBodyElem4.addTextNode(user.getFirstName()); SOAPElement soapBodyElem5 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_NAME, namespacePrefix); soapBodyElem5.addTextNode(user.getLastName()); SOAPElement soapBodyElem6 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_MAIL, namespacePrefix); soapBodyElem6.addTextNode(user.getMail()); SOAPElement soapBodyElem7 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_PHONE, namespacePrefix); soapBodyElem7.addTextNode(user.getPhone()); SOAPElement soapBodyElem8 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_STATUS, namespacePrefix); soapBodyElem8.addTextNode(user.getStatus()); SOAPElement soapBodyElem9 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_ROLE, namespacePrefix); soapBodyElem9.addTextNode(user.getRole()); SOAPElement soapBodyElem10 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_ACCESS, namespacePrefix); soapBodyElem10.addTextNode(user.getAccess()); SOAPElement soapBodyElem11 = soapBodyElem .addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_CONTENT_TYPE, namespacePrefix); soapBodyElem11.addTextNode(user.getCodeType()); SOAPElement soapBodyElem12 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_LANG, namespacePrefix); soapBodyElem12.addTextNode(user.getLanguage()); SOAPElement soapBodyElem13 = soapBodyElem .addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_EXTRA_FIELDS, namespacePrefix); soapBodyElem13.addTextNode(user.getExtraFields()); MimeHeaders headers = soapMessage.getMimeHeaders(); headers.addHeader(InweboConnectorConstants.SOAPMessage.SOAP_ACTION, serverURI + InweboConnectorConstants.SOAPMessage.SOAP_ACTION_HEADER); soapMessage.saveChanges(); return soapMessage; }
From source file:org.wso2.carbon.identity.provisioning.connector.InweboUserManager.java
private static SOAPMessage updateUserSOAPMessage(Properties inweboProperties, InweboUser user) throws SOAPException { MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage soapMessage = messageFactory.createMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); String serverURI = inweboProperties.getProperty(InweboConnectorConstants.INWEBO_URI); SOAPEnvelope envelope = soapPart.getEnvelope(); String namespacePrefix = InweboConnectorConstants.SOAPMessage.SOAP_NAMESPACE_PREFIX; envelope.addNamespaceDeclaration(namespacePrefix, serverURI); SOAPBody soapBody = envelope.getBody(); SOAPElement soapBodyElem = soapBody .addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_ACTION_LOGIN_UPDATE, namespacePrefix); SOAPElement soapBodyElem1 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_USER_ID, namespacePrefix);// w w w . ja v a 2 s.c o m soapBodyElem1.addTextNode(user.getUserId()); SOAPElement soapBodyElem2 = soapBodyElem .addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_SERVICE_ID, namespacePrefix); soapBodyElem2.addTextNode(user.getServiceId()); SOAPElement soapBodyElem3 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_LOGIN_ID, namespacePrefix); soapBodyElem3.addTextNode(user.getLoginId()); SOAPElement soapBodyElem4 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_LOGIN, namespacePrefix); soapBodyElem4.addTextNode(user.getLogin()); SOAPElement soapBodyElem5 = soapBodyElem .addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_FIRST_NAME, namespacePrefix); soapBodyElem5.addTextNode(user.getFirstName()); SOAPElement soapBodyElem6 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_NAME, namespacePrefix); soapBodyElem6.addTextNode(user.getLastName()); SOAPElement soapBodyElem7 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_MAIL, namespacePrefix); soapBodyElem7.addTextNode(user.getMail()); SOAPElement soapBodyElem8 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_PHONE, namespacePrefix); soapBodyElem8.addTextNode(user.getPhone()); SOAPElement soapBodyElem9 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_STATUS, namespacePrefix); soapBodyElem9.addTextNode(user.getStatus()); SOAPElement soapBodyElem10 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_ROLE, namespacePrefix); soapBodyElem10.addTextNode(user.getRole()); SOAPElement soapBodyElem11 = soapBodyElem .addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_EXTRA_FIELDS, namespacePrefix); soapBodyElem11.addTextNode(user.getExtraFields()); MimeHeaders headers = soapMessage.getMimeHeaders(); headers.addHeader(InweboConnectorConstants.SOAPMessage.SOAP_ACTION, serverURI + InweboConnectorConstants.SOAPMessage.SOAP_ACTION_HEADER); soapMessage.saveChanges(); return soapMessage; }
From source file:org.wso2.carbon.identity.provisioning.connector.InweboUserManager.java
private static SOAPMessage deleteUserSOAPMessage(Properties inweboProperties, String loginId, String userId, String serviceId) throws SOAPException { MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage soapMessage = messageFactory.createMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); String serverURI = inweboProperties.getProperty(InweboConnectorConstants.INWEBO_URI); SOAPEnvelope envelope = soapPart.getEnvelope(); String namespacePrefix = InweboConnectorConstants.SOAPMessage.SOAP_NAMESPACE_PREFIX; envelope.addNamespaceDeclaration(namespacePrefix, serverURI); SOAPBody soapBody = envelope.getBody(); SOAPElement soapBodyElem = soapBody .addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_ACTION_LOGIN_DELETE, namespacePrefix); SOAPElement soapBodyElem1 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_USER_ID, namespacePrefix);//from w ww.ja va 2s . c o m soapBodyElem1.addTextNode(userId); SOAPElement soapBodyElem2 = soapBodyElem .addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_SERVICE_ID, namespacePrefix); soapBodyElem2.addTextNode(serviceId); SOAPElement soapBodyElem3 = soapBodyElem.addChildElement(InweboConnectorConstants.SOAPMessage.SOAP_LOGIN_ID, namespacePrefix); soapBodyElem3.addTextNode(loginId); MimeHeaders headers = soapMessage.getMimeHeaders(); headers.addHeader(InweboConnectorConstants.SOAPMessage.SOAP_ACTION, serverURI + InweboConnectorConstants.SOAPMessage.SOAP_ACTION_HEADER); soapMessage.saveChanges(); return soapMessage; }
From source file:org.wso2.carbon.identity.provisioning.connector.UserCreation.java
private static SOAPMessage createUser(String userId, String serviceId, String login, String firstName, String name, String mail, String phone, String status, String role, String access, String codetype, String language, String extrafields) throws SOAPException, IdentityProvisioningException { MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage soapMessage = messageFactory.createMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); String serverURI = InweboConnectorConstants.INWEBO_URI; SOAPEnvelope envelope = soapPart.getEnvelope(); envelope.addNamespaceDeclaration("con", serverURI); SOAPBody soapBody = envelope.getBody(); SOAPElement soapBodyElem = soapBody.addChildElement("loginCreate", "con"); SOAPElement soapBodyElem1 = soapBodyElem.addChildElement("userid", "con"); soapBodyElem1.addTextNode(userId);/*w ww. j a v a2 s. co m*/ SOAPElement soapBodyElem2 = soapBodyElem.addChildElement("serviceid", "con"); soapBodyElem2.addTextNode(serviceId); SOAPElement soapBodyElem3 = soapBodyElem.addChildElement("login", "con"); soapBodyElem3.addTextNode(login); SOAPElement soapBodyElem4 = soapBodyElem.addChildElement("firstname", "con"); soapBodyElem4.addTextNode(firstName); SOAPElement soapBodyElem5 = soapBodyElem.addChildElement("name", "con"); soapBodyElem5.addTextNode(name); SOAPElement soapBodyElem6 = soapBodyElem.addChildElement("mail", "con"); soapBodyElem6.addTextNode(mail); SOAPElement soapBodyElem7 = soapBodyElem.addChildElement("phone", "con"); soapBodyElem7.addTextNode(phone); SOAPElement soapBodyElem8 = soapBodyElem.addChildElement("status", "con"); soapBodyElem8.addTextNode(status); SOAPElement soapBodyElem9 = soapBodyElem.addChildElement("role", "con"); soapBodyElem9.addTextNode(role); SOAPElement soapBodyElem10 = soapBodyElem.addChildElement("access", "con"); soapBodyElem10.addTextNode(access); SOAPElement soapBodyElem11 = soapBodyElem.addChildElement("codetype", "con"); soapBodyElem11.addTextNode(codetype); SOAPElement soapBodyElem12 = soapBodyElem.addChildElement("lang", "con"); soapBodyElem12.addTextNode(language); SOAPElement soapBodyElem13 = soapBodyElem.addChildElement("extrafields", "con"); soapBodyElem13.addTextNode(extrafields); MimeHeaders headers = soapMessage.getMimeHeaders(); headers.addHeader("SOAPAction", serverURI + "/services/ConsoleAdmin"); soapMessage.saveChanges(); return soapMessage; }