soap消息代码片段如下:<soap:Body>
<DocumentLiteral xmlns="http://www.contoso.com">
<address>
<Street>One Microsoft Way</Street>
<City>Redmond</City>
<Zip>98052</Zip>
</address>
</DocumentLiteral>
</soap:Body>
</soap:Envelope>我想将<address>显示为<ws:address>的方法,如何处理,其他的参数也是按此类型显示
望各位高手不吝赐教,先行谢过.
<DocumentLiteral xmlns="http://www.contoso.com">
<address>
<Street>One Microsoft Way</Street>
<City>Redmond</City>
<Zip>98052</Zip>
</address>
</DocumentLiteral>
</soap:Body>
</soap:Envelope>我想将<address>显示为<ws:address>的方法,如何处理,其他的参数也是按此类型显示
望各位高手不吝赐教,先行谢过.
解决方案 »
- spring中复杂bean如何设置为组件
- Spring MVC 热部署的问题
- jsp中button按钮是否可以携带数据跳转到另一个页面?
- 各位大虾,有个关于corba的问题请教
- 总出差程序员应该有的
- 请大家谈谈包含大量数据库操作的测试如何进行?
- 请问怎么使用tomcat(最好详细一点)
- 请教一个有关servlet的简单问题
- 关于JBOSS的小问题
- javaweb hibernate
- 基于Axis开发webservice, 客户端是否也要安装Axis
- eclipse 自动生成web services client 的问题: 读服务器端读一个xml文件, 返回string, 用web service 客户端远程调用,为什么得到的总是null
* 创建xml
*
* @param method
* 要访问的方法(webservice专用)
* @param path
* xml路径
* @param elements
* 子元素
*/
static public Document createXML(Element method, String path,
Element... elements)
{
// declare root element
Element root = new Element("Envelope");
// declare header element
Element header = new Element("Header");
// declare body element
Element body = new Element("Body");
// declare three namespaces
// first param is prefixs,second param is uri
Namespace soap = Namespace.getNamespace("soap",
"http://schemas.xmlsoap.org/soap/envelope/");
Namespace xsd = Namespace.getNamespace("xsd",
"http://www.w3.org/2001/XMLSchema");
Namespace xsi = Namespace.getNamespace("xsi",
"http://www.w3.org/2001/XMLSchema-instance");
// put namespace to root element
root.addNamespaceDeclaration(soap);
root.addNamespaceDeclaration(xsd);
root.addNamespaceDeclaration(xsi);
// put header element to root element
root.addContent(header);
// put body element to root element
root.addContent(body);
// with root set namespace prefixs
root.setNamespace(soap);
// with header set namespace prefix
header.setNamespace(soap); // with body element set namespace prefixs
body.setNamespace(soap);
body.addContent(method); for (int i = 0; i < elements.length; ++i)
{
method.addContent(elements[i]);
}
// declare document element
Document doc = new Document(root);
// declare xml format class
Format format = Format.getPrettyFormat();
// set encoding for xml
format.setEncoding("UTF-8");
// set indent for xml
format.setIndent(" ");
// set expaned empty elements for xml
format.setExpandEmptyElements(true);
// xml file output class
XMLOutputter outputter = new XMLOutputter(format);
// output
try
{
outputter.output(doc, new FileWriter(path));
} catch (IOException e)
{
e.printStackTrace();
System.out.println("File path is not correct!" + e.getMessage());
}
return doc;
}