protected SOAPFactory newSOAPFactory(String protocol) throws SOAPException { if (SOAPConstants.SOAP_1_1_PROTOCOL.equals(protocol)) { return new com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl(); } else if (SOAPConstants.SOAP_1_2_PROTOCOL.equals(protocol)) { return new com.sun.xml.internal.messaging.saaj.soap.ver1_2.SOAPFactory1_2Impl(); } else if (SOAPConstants.DYNAMIC_SOAP_PROTOCOL.equals(protocol)) { return new com.sun.xml.internal.messaging.saaj.soap.dynamic.SOAPFactoryDynamicImpl(); } else { log.log( Level.SEVERE, "SAAJ0569.soap.unknown.protocol", new Object[] {protocol, "SOAPFactory"}); throw new SOAPException("Unknown Protocol: " + protocol + " specified for creating SOAPFactory"); } }
@Override protected SOAPFactory newSOAPFactory(String protocol) throws SOAPException { if (SOAPConstants.SOAP_1_1_PROTOCOL.equals(protocol)) { return new com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl(); } else if (SOAPConstants.SOAP_1_2_PROTOCOL.equals(protocol)) { return new com.sun.xml.internal.messaging.saaj.soap.ver1_2.SOAPFactory1_2Impl(); } else if (SOAPConstants.DYNAMIC_SOAP_PROTOCOL.equals(protocol)) { return new com.sun.xml.internal.messaging.saaj.soap.dynamic.SOAPFactoryDynamicImpl(); } else { log.log( Level.SEVERE, "SAAJ0569.soap.unknown.protocol", new Object[] {protocol, "SOAPFactory"}); throw new SOAPException("Unknown Protocol: " + protocol + " specified for creating SOAPFactory"); } }
/** * Get a SOAP document fragment representing this object. * * @return A SOAPElement representing this object. * @throws SOAPException * If an error occurred when trying to construct this element. */ public SOAPElement getSOAPElement() throws SOAPException { // Create the parent node SOAPElement answer = SOAPFactory.newInstance() .createElement("SetPatientImmediate3") .addAttribute(new QName("xmlns"), "http://www.zoommed.com/"); // Add all the data we need answer.addChildElement(this.transaction.getSOAPElement()); answer.addChildElement(this.patient.getSOAPElement()); answer.addChildElement("username").addTextNode(this.username); answer.addChildElement("password").addTextNode(this.password); answer.addChildElement("localeId").addTextNode(this.localeId); answer.addChildElement("clientNumber").addTextNode(this.clientNumber); answer.addChildElement("isTraining").addTextNode( this.isTraining ? "1" : "0"); // Return the finished body return answer; }
/** * Get a SOAP document fragment representing this object. * * @return A SOAPElement representing this transaction. * @throws SOAPException * If an error occurred when trying to construct the element. */ public SOAPElement getSOAPElement() throws SOAPException { SOAPElement answer = SOAPFactory.newInstance().createElement( "transaction"); String transId = ""; if (this.transactionId >= Integer.MAX_VALUE) { //bit shift to get the right most 32 bit values transId = Integer.toString((int) (this.transactionId << 32)); } else { transId = Integer.toString((int) this.transactionId); } answer.addChildElement("TransactionId").addTextNode(transId); answer.addChildElement("Engine").addTextNode(this.engine); answer.addChildElement("Sender").addTextNode(this.sender); answer.addChildElement("Version").addTextNode(this.version); answer.addChildElement("PMISLastUpdate").addTextNode( Transaction3.formatDateTime(this.pmisLastUpdate)); return answer; }
/** * Create a SOAP Element with the specified parameters.<p> * * @param tagName the name of XML tag. * @param tagValue the value of XML tag. * @param nsPrefix the namespace prefix. * @param nsURI the namespace URL. * * @return the new SOAP element created. */ public static SOAPElement createElement(String tagName ,String tagValue ,String nsPrefix ,String nsURI) throws SOAPException { // Create a new SOAP Element according to tagname, prefix, uri // and the text value. SOAPElement soapElement = null; if (nsURI != null) soapElement = SOAPFactory.newInstance().createElement(tagName, nsPrefix, nsURI); else soapElement = SOAPFactory.newInstance().createElement(tagName); if (tagValue == null) tagValue = ""; soapElement.addTextNode(tagValue); return soapElement; }
/** * Create a SOAP Element with the specified parameters.<p> * * Also it create the attributes set as the parameter properties. * * @param tagName the name of XML tag. * @param tagValue the value of XML tag. * @param nsPrefix the namespace prefix. * @param nsURI the namespace URL. * @param attrSet the attributes set in the element. * * @return the new SOAP element created. */ public static SOAPElement createElement(String tagName ,String tagValue ,String nsPrefix ,String nsURI ,Hashtable attrSet) throws SOAPException { SOAPElement newElem = SOAPUtilities.createElement(tagName, tagValue, nsPrefix, nsURI); if (newElem == null || attrSet.size() == 0) return newElem; // Iterate all attributes in the set. Enumeration keys = attrSet.keys(); while (keys.hasMoreElements()){ Object key = keys.nextElement(); Object value = attrSet.get(key); // Create SOAP Name for the tag. Name attrName = SOAPFactory.newInstance().createName(key.toString(), null, null); newElem.addAttribute(attrName, value.toString()); } return newElem; }
@Override public DOMSource invoke(DOMSource request) { try { return invokeAllowingFaults(request); } catch (FaultMessage faultMessage) { try { SOAPFactory factory = SOAPFactory.newInstance(); SOAPFault soapFault = factory.createFault(); soapFault.setFaultCode(SOAP11_FAULTCODE_SERVER); // todo here is a constant until we have a mechanism to determine the correct value (client / server) soapFault.setFaultString(faultMessage.getMessage()); Detail detail = soapFault.addDetail(); serializeFaultMessage(detail, faultMessage); // fault actor? // stack trace of the outer exception (FaultMessage) is unimportant, because it is always created at one place // todo consider providing stack trace of the inner exception //Detail detail = soapFault.addDetail(); //detail.setTextContent(getStackTraceAsString(faultMessage)); throw new SOAPFaultException(soapFault); } catch (SOAPException e) { throw new RuntimeException("SOAP Exception: " + e.getMessage(), e); } } }
protected void createBody(SOAPBodyElement body, SOAPFactory spf) throws SOAPException { SOAPElement elm = body.addChildElement(spf.createName("ParameterList")); elm.setAttribute(SOAP_ARRAY_TYPE, "cwmp:SetParameterAttributesStruct[" + String.valueOf(attrs.size()) + "]"); int c = attrs.size(); for (int i = 0; i < c; i++) { SOAPElement param = elm.addChildElement("SetParameterAttributesStruct"); param.addChildElement("Name").setValue(attrs.get(i).Name); param.addChildElement("NotificationChange").setValue(b2s(attrs.get(i).NotificationChange)); param.addChildElement("Notification").setValue(String.valueOf(attrs.get(i).Notification)); param.addChildElement("AccessListChange").setValue(b2s(attrs.get(i).AccessListChange)); SOAPElement al = param.addChildElement(spf.createName("AccessList")); String acl[] = attrs.get(i).AccessList; int ca = acl.length; al.setAttribute(SOAP_ARRAY_TYPE, "xsd:string[" + String.valueOf(ca) + "]"); for (int i2 = 0; i2 < ca; i2++) { SOAPElement acle = al.addChildElement("string"); acle.setValue(acl[i2]); acle.setAttribute(XSI_TYPE, XSD_STRING); } } }
@Override protected void parseBody(SOAPBodyElement body, SOAPFactory spf) throws SOAPException { Iterator pi = getRequestChildElement(spf, body, "ExecResponseList").getChildElements(spf.createName("ExecResponseStruct")); Name nameKey = spf.createName("Command"); Name nameValue = spf.createName("Response"); while (pi.hasNext()) { SOAPElement param = (SOAPElement) pi.next(); String key = getRequestElement(param, nameKey); String value = getRequestElement(param, nameValue); if (value == null) { value = ""; } System.out.append(key + "->" + value); response.put(key, value); } }
@Override protected SOAPFactory initialValue() { try { return SOAPFactory.newInstance(); } catch (SOAPException e) { e.printStackTrace(); return null; } }
public SOAPFault createInvalidAddressingHeaderFault(InvalidAddressingHeaderException e, AddressingVersion av) { QName name = e.getProblemHeader(); QName subsubcode = e.getSubsubcode(); QName subcode = av.invalidMapTag; String faultstring = String.format(av.getInvalidMapText(), name, subsubcode); try { SOAPFactory factory; SOAPFault fault; if (soapVer == SOAPVersion.SOAP_12) { factory = SOAPVersion.SOAP_12.getSOAPFactory(); fault = factory.createFault(); fault.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT); fault.appendFaultSubcode(subcode); fault.appendFaultSubcode(subsubcode); getInvalidMapDetail(name, fault.addDetail()); } else { factory = SOAPVersion.SOAP_11.getSOAPFactory(); fault = factory.createFault(); fault.setFaultCode(subsubcode); } fault.setFaultString(faultstring); return fault; } catch (SOAPException se) { throw new WebServiceException(se); } }
public SOAPFault newMapRequiredFault(MissingAddressingHeaderException e) { QName subcode = addVer.mapRequiredTag; QName subsubcode = addVer.mapRequiredTag; String faultstring = addVer.getMapRequiredText(); try { SOAPFactory factory; SOAPFault fault; if (soapVer == SOAPVersion.SOAP_12) { factory = SOAPVersion.SOAP_12.getSOAPFactory(); fault = factory.createFault(); fault.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT); fault.appendFaultSubcode(subcode); fault.appendFaultSubcode(subsubcode); getMapRequiredDetail(e.getMissingHeaderQName(), fault.addDetail()); } else { factory = SOAPVersion.SOAP_11.getSOAPFactory(); fault = factory.createFault(); fault.setFaultCode(subsubcode); } fault.setFaultString(faultstring); return fault; } catch (SOAPException se) { throw new WebServiceException(se); } }
/** * Creates a new instance of MessageFactory. * * @throws RequestListenerException if unable to create MessageFactory. * @see hk.hku.cecid.piazza.commons.servlet.RequestListener#listenerCreated() */ public void listenerCreated() throws RequestListenerException { try { msgFactory = MessageFactory.newInstance(); soapFactory = SOAPFactory.newInstance(); } catch (Exception e) { throw new RequestListenerException( "Unable to create SOAP factories", e); } }
@Override protected void parseBody(SOAPBodyElement body, SOAPFactory spf) throws SOAPException { SOAPElement ml = getRequestChildElement(spf, body, "MethodList"); int i = getArrayCount(spf, ml); // Iterator mlist = ml.getChildElements(spf.createName("string")); Iterator mlist = ml.getChildElements(); //methods = new String [i]; ArrayList<String> m = new ArrayList<String>(); i = 0; while (mlist.hasNext()) { Object e = mlist.next(); if (e instanceof SOAPElement) { SOAPElement el = (SOAPElement) e; if (el.getElementQName().getLocalPart().equals("string")) { // methods[i++] = el.getValue(); m.add(el.getValue()); } } } methods = m.toArray(new String[1]); /* mlist = ml.getChildElements(type.getType(body,spf)); while (mlist.hasNext()) { methods[i++] = ((SOAPElement)mlist.next()).getValue(); } */ }
protected void createBody(SOAPBodyElement body, SOAPFactory spf) throws SOAPException { body.addChildElement(COMMAND_KEY).setValue(CommandKey); body.addChildElement("FileType").setValue(FileType); body.addChildElement("URL").setValue(url); body.addChildElement("Username").setValue(UserName); body.addChildElement("Password").setValue(Password); body.addChildElement("FileSize").setValue(String.valueOf(FileSize)); body.addChildElement("TargetFileName").setValue(TargetFileName); body.addChildElement("DelaySeconds").setValue(String.valueOf(DelaySeconds)); body.addChildElement("SuccessURL").setValue(SuccessUrl); body.addChildElement("FailureURL").setValue(FailureUrl); }
protected void createBody(SOAPBodyElement body, SOAPFactory spf) throws SOAPException { body.addChildElement(COMMAND_KEY).setValue(CommandKey); body.addChildElement("FileType").setValue(FileType); body.addChildElement("URL").setValue(URL); body.addChildElement("Username").setValue(Username); body.addChildElement("Password").setValue(Password); body.addChildElement("DelaySeconds").setValue(String.valueOf(DelaySeconds)); }
protected void createBody(SOAPBodyElement body, SOAPFactory spf) throws SOAPException { SOAPElement elm = body.addChildElement(spf.createName("ParameterNames")); elm.setAttribute(SOAP_ARRAY_TYPE, "xsd:string[" + String.valueOf(parameterNames.length) + "]"); for (int i = 0; i < parameterNames.length; i++) { SOAPElement s = elm.addChildElement("string"); s.setValue(parameterNames[i]); // s.setAttribute("xsi:type","xsd:string"); } }
protected void parseBody(SOAPBodyElement body, SOAPFactory spf) throws SOAPException { StartTime = getRequestElement(spf, body, "StartTime"); CompleteTime = getRequestElement(spf, body, "CompleteTime"); CommandKey = getRequestElement(spf, body, COMMAND_KEY); SOAPElement fault = getRequestChildElement(spf, body, "FaultStruct"); if (fault != null) { FaultCode = Integer.parseInt(getRequestElement(spf, fault, "FaultCode")); FaultString = getRequestElement(spf, fault, "FaultString"); } else { FaultCode = 0; FaultString = null; } }
protected void createBody(SOAPBodyElement body, SOAPFactory spf) throws SOAPException { SOAPElement elm = body.addChildElement(spf.createName("ParameterNames")); elm.setAttribute(SOAP_ARRAY_TYPE, "xsd:string[" + String.valueOf(parameterNames.length) + "]"); for (int i = 0; i < parameterNames.length; i++) { elm.addChildElement("string").setValue(parameterNames[i]); } }
@Override protected void createBody(SOAPBodyElement body, SOAPFactory spf) throws SOAPException { body.addChildElement(spf.createName("ErrorOption")).setValue(ErrorOption); body.addChildElement(spf.createName("Target")).setValue(Target); SOAPElement elm = body.addChildElement(spf.createName("ConfigCommandList")); elm.setAttribute(SOAP_ARRAY_TYPE, "xsd:string[" + String.valueOf(ConfigCommandList.size()) + "]"); for (int i = 0; i < ConfigCommandList.size(); i++) { SOAPElement s = elm.addChildElement("string"); s.setValue(ConfigCommandList.get(i)); } body.addChildElement(spf.createName("ParameterKey")).setValue(ParameterKey); }
@Override protected void createBody(SOAPBodyElement body, SOAPFactory spf) throws SOAPException { SOAPElement elm = body.addChildElement(spf.createName("ExecCommandList")); elm.setAttribute(SOAP_ARRAY_TYPE, "xsd:string[" + String.valueOf(ExecCommandList.size()) + "]"); for (int i = 0; i < ExecCommandList.size(); i++) { SOAPElement s = elm.addChildElement("string"); s.setValue(ExecCommandList.get(i)); // s.setAttribute("xsi:type","xsd:string"); } }
@Override protected void parseBody(SOAPBodyElement body, SOAPFactory spf) throws SOAPException { Iterator pi = getRequestChildElement(spf, body, "TransferList").getChildElements(spf.createName("QueuedTransferStruct")); Name nameCommandKey = spf.createName(COMMAND_KEY); Name nameState = spf.createName("State"); TransferList = new Hashtable<String, String>(); while (pi.hasNext()) { SOAPElement param = (SOAPElement) pi.next(); String key = getRequestElement(param, nameCommandKey); String state = getRequestElement(param, nameState); TransferList.put(key, state); } }
protected void parseBody(SOAPBodyElement body, SOAPFactory spf) throws SOAPException { SOAPElement ml = getRequestChildElement(spf, body, "ParameterList"); int i = getArrayCount(spf, ml); Iterator mlist = ml.getChildElements(spf.createName("ParameterAttributeStruct")); attributes = new ParameterAttributeStruct[i]; Name nameKey = spf.createName("Name"); Name nameNotification = spf.createName("Notification"); Name nameAccessList = spf.createName("AccessList"); Name nameString = spf.createName("string"); //System.out.println ("start "+i); i = 0; while (mlist.hasNext()) { SOAPElement param = (SOAPElement) mlist.next(); attributes[i] = new ParameterAttributeStruct(); attributes[i].Name = getRequestElement(param, nameKey); attributes[i].Notification = Integer.parseInt(getRequestElement(param, nameNotification)); //System.out.println ("Attrbiute: name="+attributes[i].Name+", notification="+attributes[i].Notification); // get acl array SOAPElement elementAccessList = getRequestChildElement(spf, param, "AccessList"); int ii = getArrayCount(spf, elementAccessList); attributes[i].AccessList = new String[ii]; System.out.println("Access list length: " + ii); ii = 0; Iterator iteratorAccessList = elementAccessList.getChildElements(nameString); while (iteratorAccessList.hasNext()) { attributes[i].AccessList[ii++] = ((SOAPElement) iteratorAccessList.next()).getValue(); //System.out.println ("acl= "+attributes[i].AccessList[ii-1]); } i++; } }
public SOAPFactory getSOAPFactory() { return soapVersion.getSOAPFactory(); }
@Override protected void createBody(SOAPBodyElement body, SOAPFactory spf) throws SOAPException { throw new UnsupportedOperationException("Not implemented."); }
protected void parseBody(SOAPBodyElement body, SOAPFactory f) throws SOAPException { }
/** * Get a SOAP document fragment representing this object. * * @return A SOAPElement representing this patient data. * @throws SOAPException * If an error occurred when trying to construct the element. */ public SOAPElement getSOAPElement() throws SOAPException { SOAPElement answer = SOAPFactory.newInstance().createElement("patient"); answer.addChildElement("PatientId").addTextNode(this.patientId); answer.addChildElement("MergeToId").addTextNode(this.mergeToId); answer.addChildElement("Delete").addTextNode( Integer.toString(this.delete)); answer.addChildElement("Firstname").addTextNode(this.firstname); answer.addChildElement("Lastname").addTextNode(this.lastname); answer.addChildElement("MiddleName").addTextNode(this.middleName); answer.addChildElement("NameSuffix").addTextNode(this.nameSuffix); answer.addChildElement("NamePrefix").addTextNode(this.namePrefix); answer.addChildElement("DateOfBirth").addTextNode(this.birthdate); if (this.validBirthDate != null) { answer.addChildElement("CleanDateOfBirth").addTextNode( ERxPatientData.formatDate(this.validBirthDate)); } answer.addChildElement("Gender").addTextNode(this.gender); answer.addChildElement("Address").addTextNode(this.address); answer.addChildElement("City").addTextNode(this.city); answer.addChildElement("State").addTextNode(this.state); answer.addChildElement("ZipCode").addTextNode(this.zipCode); answer.addChildElement("Phone1").addTextNode(this.phone1); answer.addChildElement("Phone2").addTextNode(this.phone2); answer.addChildElement("ChartNumber").addTextNode(this.chartNumber); answer.addChildElement("AltChartNumber").addTextNode( this.altChartNumber); answer.addChildElement("PIN1").addTextNode(this.pin1); if (this.pin1type != null) { answer.addChildElement("PIN1type").addTextNode( Integer.toString(this.pin1type)); } answer.addChildElement("PIN1Expiration").addTextNode( this.pin1Expiration); answer.addChildElement("PIN2").addTextNode(this.pin2); if (this.pin2type != null) { answer.addChildElement("PIN2type").addTextNode( Integer.toString(this.pin2type)); } answer.addChildElement("PIN2Expiration").addTextNode( this.pin2Expiration); answer.addChildElement("PIN3").addTextNode(this.pin3); if (this.pin3type != null) { answer.addChildElement("PIN3type").addTextNode( Integer.toString(this.pin3type)); } answer.addChildElement("PIN3Expiration").addTextNode( this.pin3Expiration); if (this.hip != null) { answer.addChildElement("HIP").addTextNode( Integer.toString(this.hip)); } return answer; }
protected void createBody(SOAPBodyElement body, SOAPFactory spf) throws SOAPException { }