本文整理匯總了Java中javax.xml.soap.SOAPEnvelope.createName方法的典型用法代碼示例。如果您正苦於以下問題:Java SOAPEnvelope.createName方法的具體用法?Java SOAPEnvelope.createName怎麽用?Java SOAPEnvelope.createName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.xml.soap.SOAPEnvelope
的用法示例。
在下文中一共展示了SOAPEnvelope.createName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createMessage
import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
private SOAPMessage createMessage(MessageFactory mf) throws SOAPException, IOException {
SOAPMessage msg = mf.createMessage();
SOAPEnvelope envelope = msg.getSOAPPart().getEnvelope();
Name name = envelope.createName("hello", "ex", "http://example.com");
envelope.getBody().addChildElement(name).addTextNode("THERE!");
String s = "<root><hello>THERE!</hello></root>";
AttachmentPart ap = msg.createAttachmentPart(
new StreamSource(new ByteArrayInputStream(s.getBytes())),
"text/xml"
);
msg.addAttachmentPart(ap);
msg.saveChanges();
return msg;
}
示例2: createSimpleSOAPPart
import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
private void createSimpleSOAPPart(SOAPMessage message) throws SOAPException {
SOAPPart sPart = message.getSOAPPart();
SOAPEnvelope env = sPart.getEnvelope();
SOAPBody body = env.getBody();
SOAPHeader header = env.getHeader();
header.addHeaderElement(env.createName("Header1",
"pref",
"http://test.apach.org/test"))
.addTextNode("This is header1");
Name ns = env.createName("echo", "swa2", "http://fakeNamespace2.org");
final SOAPBodyElement bodyElement = body.addBodyElement(ns);
Name ns2 = env.createName("something");
final SOAPElement ele1 = bodyElement.addChildElement(ns2);
ele1.addTextNode("This is some text");
Name ns3 = env.createName("ping", "swa3", "http://fakeNamespace3.org");
final SOAPBodyElement bodyElement2 = body.addBodyElement(ns3);
Name ns4 = env.createName("another");
final SOAPElement ele2 = bodyElement2.addChildElement(ns4);
ele2.addTextNode("This is another text");
}
示例3: writeTerminalResponse
import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
/**
* Gets the terminal response.
*
* @param message
* @throws SOAPException
*/
private void writeTerminalResponse(SOAPMessage message) throws SOAPException {
SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
Name terminalResponseName = envelope.createName("EditTerminalResponse", PREFIX, NAMESPACE_URI);
SOAPBodyElement terminalResponseElement = (SOAPBodyElement) message.getSOAPBody().getChildElements(terminalResponseName).next();
NodeList list = terminalResponseElement.getChildNodes();
Node n = null;
for (int i = 0; i < list.getLength(); i++) {
n = list.item(i);
if ("status".equalsIgnoreCase(n.getLocalName()))
break;
}
logger.info("status of device = " + n.getNodeValue());
}
示例4: createTerminalRequest
import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
/**
* This method creates a Terminal Request and sends back the SOAPMessage.
* MSISDN value is passed into this method
*
* @param msisdn
* @return
* @throws SOAPException
*/
private SOAPMessage createTerminalRequest(String msisdn) throws SOAPException {
SOAPMessage message = messageFactory.createMessage();
message.getMimeHeaders().addHeader("SOAPAction", "http://api.jasperwireless.com/ws/service/terminal/GetTerminalsByMsisdn");
SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
Name terminalRequestName = envelope.createName("GetTerminalsByMsisdnRequest", PREFIX, NAMESPACE_URI);
SOAPBodyElement terminalRequestElement = message.getSOAPBody().addBodyElement(terminalRequestName);
Name msgId = envelope.createName("messageId", PREFIX, NAMESPACE_URI);
SOAPElement msgElement = terminalRequestElement.addChildElement(msgId);
msgElement.setValue("TCE-100-ABC-34084");
Name version = envelope.createName("version", PREFIX, NAMESPACE_URI);
SOAPElement versionElement = terminalRequestElement.addChildElement(version);
versionElement.setValue("1.0");
Name license = envelope.createName("licenseKey", PREFIX, NAMESPACE_URI);
SOAPElement licenseElement = terminalRequestElement.addChildElement(license);
licenseElement.setValue(apiKey);
Name msisdns = envelope.createName("msisdns", PREFIX, NAMESPACE_URI);
SOAPElement msisdnsElement = terminalRequestElement.addChildElement(msisdns);
Name msisdnName = envelope.createName("msisdn", PREFIX, NAMESPACE_URI);
SOAPElement msisdnElement = msisdnsElement.addChildElement(msisdnName);
msisdnElement.setValue(msisdn);
return message;
}
示例5: writeTerminalResponse
import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
/**
* Gets the terminal response.
*
* @param message
* @throws SOAPException
*/
private String writeTerminalResponse(SOAPMessage message) throws SOAPException {
SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
Name terminalResponseName = envelope.createName("GetTerminalsByMsisdnResponse", PREFIX, NAMESPACE_URI);
SOAPBodyElement terminalResponseElement = (SOAPBodyElement) message.getSOAPBody().getChildElements(terminalResponseName).next();
Name terminals = envelope.createName("terminals", PREFIX, NAMESPACE_URI);
Name terminal = envelope.createName("terminal", PREFIX, NAMESPACE_URI);
SOAPBodyElement terminalsElement = (SOAPBodyElement) terminalResponseElement.getChildElements(terminals).next();
SOAPBodyElement terminalElement = (SOAPBodyElement) terminalsElement.getChildElements(terminal).next();
NodeList list = terminalElement.getChildNodes();
Node n = null, node = null;
for (int i = 0; i < list.getLength(); i++) {
node = list.item(i);
logger.info(node.getLocalName() + ":" + node.getFirstChild().getNodeValue());
if ("iccid".equalsIgnoreCase(node.getLocalName())) {
n = node;
}
}
return n.getFirstChild().getNodeValue();
}
示例6: addParameterList
import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
protected void addParameterList(SOAPEnvelope envelope, SOAPElement eParent, String typeName, String listName, Map<String, String> params) throws SOAPException
{
Name nPara = envelope.createName(typeName, "", XMLA_URI);
SOAPElement eType = eParent.addChildElement(nPara);
nPara = envelope.createName(listName, "", XMLA_URI);
SOAPElement eList = eType.addChildElement(nPara);
if (params == null)
{
return;
}
for (Iterator<Map.Entry<String, String>> entryIt = params.entrySet().iterator(); entryIt.hasNext();)
{
Map.Entry<String, String> entry = entryIt.next();
String tag = entry.getKey();
String value = entry.getValue();
nPara = envelope.createName(tag, "", XMLA_URI);
SOAPElement eTag = eList.addChildElement(nPara);
eTag.addTextNode(value);
}
}
示例7: onMessage
import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
public SOAPMessage onMessage(SOAPMessage msg){
//handles the response back from the registry
PrintStream orig = System.out;
try {
SOAPEnvelope env = msg.getSOAPPart().getEnvelope();
Name response = env.createName("response");
env.getBody().getChildElements(response);
} catch (SOAPException ex) {
ByteArrayOutputStream logarray = new ByteArrayOutputStream();
ex.printStackTrace(writeErrorlog(logarray));
logstring = logarray.toString();
setlogmsg(logstring);
}
return msg;
}
示例8: addParameterList
import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
/**
* Add the all the specified parameters to the discover request message
*
* @param envelope the envelope of the message
* @param eParent the discover query content
* @param typeName the type of the parameter list (essentially can be or Properties or Restrictions)
* @param listName the name of the list parameter tag (essentially can be or PropertyList or RestrictionList)
* @param params parameters map where the key is the name of the parameter and the value is the value of the parameter
* @throws SOAPException
*/
protected void addParameterList(SOAPEnvelope envelope, SOAPElement eParent, String typeName, String listName, Map<String, String> params) throws SOAPException
{
Name nPara = envelope.createName(typeName, "", XMLA_URI);
SOAPElement eType = eParent.addChildElement(nPara);
nPara = envelope.createName(listName, "", XMLA_URI);
SOAPElement eList = eType.addChildElement(nPara);
if (params == null)
return;
Iterator<String> it = params.keySet().iterator();
while (it.hasNext())
{
String tag = (String) it.next();
String value = (String) params.get(tag);
nPara = envelope.createName(tag, "", XMLA_URI);
SOAPElement eTag = eList.addChildElement(nPara);
eTag.addTextNode(value);
}
}
示例9: getDatasources
import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
/**
* Return an array of the datasources in the server, could be null
* @return array of datasources
*/
public DataSourceTreeElement[] getDatasources() {
setRequestType("DISCOVER_DATASOURCES");
SOAPMessage response = executeDiscover(new HashMap<String, String>());
SOAPPart soapPart = response.getSOAPPart();
SOAPEnvelope soapEnvelope;
try {
soapEnvelope = soapPart.getEnvelope();
SOAPElement rowSet = getRowsSet(response, soapEnvelope);
List<DataSourceTreeElement> result = new ArrayList<DataSourceTreeElement>();
Name rowElement = soapEnvelope.createName("row", "", ROW_URI);
Iterator<?> rowValuesElement = rowSet.getChildElements(rowElement);
while (rowValuesElement.hasNext())
{
SOAPElement cellElement = (SOAPElement)rowValuesElement.next();
result.add(new DataSourceElement(this, cellElement));
}
return result.toArray(new DataSourceTreeElement[result.size()]);
} catch (SOAPException e) {
e.printStackTrace();
}
return null;
}
示例10: getCatalogList
import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
/**
* Return an array of the catalogs in the server for a specific datasource, could be null
* @param datasourceName the name of the datasource
* @return array of catalogs
*/
public DataSourceTreeElement[] getCatalogList(String datasourceName) {
setRequestType("DBSCHEMA_CATALOGS");
HashMap<String, String> param = new HashMap<String, String>();
param.put("DataSourceInfo", datasourceName);
SOAPMessage response = executeDiscover(param);
SOAPPart soapPart = response.getSOAPPart();
SOAPEnvelope soapEnvelope;
try {
soapEnvelope = soapPart.getEnvelope();
SOAPElement rowSet = getRowsSet(response, soapEnvelope);
List<DataSourceTreeElement> result = new ArrayList<DataSourceTreeElement>();
Name rowElement = soapEnvelope.createName("row", "", ROW_URI);
Iterator<?> rowValuesElement = rowSet.getChildElements(rowElement);
while (rowValuesElement.hasNext())
{
SOAPElement cellElement = (SOAPElement)rowValuesElement.next();
result.add(new CatalogElement(this, cellElement, datasourceName));
}
return result.toArray(new DataSourceTreeElement[result.size()]);
} catch (SOAPException e) {
e.printStackTrace();
}
return null;
}
示例11: getCubeList
import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
/**
* Return an array of the cubes in the server for a specific datasource and catalog, could be null
* @param datasourceName the name of the datasource
* @param catalogName the name of the catalog
* @return array of cubes
*/
public DataSourceTreeElement[] getCubeList(String datasourceName, String catalogName) {
setRequestType("MDSCHEMA_CUBES");
HashMap<String, String> param = new HashMap<String, String>();
param.put("DataSourceInfo", datasourceName);
param.put("Catalog", catalogName);
SOAPMessage response = executeDiscover(param);
SOAPPart soapPart = response.getSOAPPart();
SOAPEnvelope soapEnvelope;
try {
soapEnvelope = soapPart.getEnvelope();
SOAPElement rowSet = getRowsSet(response, soapEnvelope);
List<DataSourceTreeElement> result = new ArrayList<DataSourceTreeElement>();
Name rowElement = soapEnvelope.createName("row", "", ROW_URI);
Iterator<?> rowValuesElement = rowSet.getChildElements(rowElement);
while (rowValuesElement.hasNext())
{
SOAPElement cellElement = (SOAPElement)rowValuesElement.next();
result.add(new CubeElement(this, cellElement, datasourceName));
}
return result.toArray(new DataSourceTreeElement[result.size()]);
} catch (SOAPException e) {
e.printStackTrace();
}
return null;
}
示例12: addParameterList
import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
protected void addParameterList(SOAPEnvelope envelope, SOAPElement eParent, String typeName, String listName, Map params) throws SOAPException
{
Name nPara = envelope.createName(typeName, "", XMLA_URI);
SOAPElement eType = eParent.addChildElement(nPara);
nPara = envelope.createName(listName, "", XMLA_URI);
SOAPElement eList = eType.addChildElement(nPara);
if (params == null)
return;
Iterator it = params.keySet().iterator();
while (it.hasNext())
{
String tag = (String) it.next();
String value = (String) params.get(tag);
nPara = envelope.createName(tag, "", XMLA_URI);
SOAPElement eTag = eList.addChildElement(nPara);
eTag.addTextNode(value);
}
}
示例13: _testFaults2
import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
public void _testFaults2() throws Exception {
SOAPEnvelope envelope = getSOAPEnvelope();
SOAPBody body = envelope.getBody();
SOAPFault fault = body.addFault();
assertTrue(body.getFault() != null);
Detail d1 = fault.addDetail();
Name name = envelope.createName("GetLastTradePrice", "WOMBAT",
"http://www.wombat.org/trader");
d1.addDetailEntry(name);
Detail d2 = fault.getDetail();
assertTrue(d2 != null);
Iterator i = d2.getDetailEntries();
assertTrue(getIteratorCount(i) == 1);
i = d2.getDetailEntries();
while (i.hasNext()) {
DetailEntry de = (DetailEntry)i.next();
assertEquals(de.getElementName(), name);
}
}
示例14: testRemoveAttributeName
import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
@Validated @Test
public void testRemoveAttributeName() throws Exception {
SOAPMessage msg = MessageFactory.newInstance().createMessage();
SOAPEnvelope envelope = msg.getSOAPPart().getEnvelope();
SOAPBody body = envelope.getBody();
Name name = envelope.createName("MyAttr1");
String value = "MyValue1";
body.addAttribute(name, value);
boolean b = body.removeAttribute(name);
assertTrue(b);
b = body.removeAttribute(name);
assertTrue(!b);
String s = body.getAttributeValue(name);
assertNull(s);
}
示例15: testGetChildElements2
import javax.xml.soap.SOAPEnvelope; //導入方法依賴的package包/類
@Validated @Test
public void testGetChildElements2() throws Exception {
MessageFactory fact = MessageFactory.newInstance();
SOAPMessage message = fact.createMessage();
SOAPPart soapPart = message.getSOAPPart();
SOAPEnvelope soapEnvelope = soapPart.getEnvelope();
SOAPBody soapBody = soapEnvelope.getBody();
Name name = soapEnvelope.createName("MyChild1");
SOAPElement se = soapBody.addChildElement(name);
Iterator childElementsCount = soapBody.getChildElements();
Iterator childElements = soapBody.getChildElements();
int childCount = 0;
while (childElementsCount.hasNext()) {
Node node = (Node)childElementsCount.next();
childCount++;
}
assertEquals(childCount, 1);
SOAPElement se2 = (SOAPElement)childElements.next();
if (!se.equals(se2)) {
fail();
} else {
System.out.println("SOAPElement se = se2 (expected)");
}
Name n = se.getElementName();
assertEquals(n, name);
}