折腾了一把JAX-WS, SOA & Java EE 5(part 2 of 3)
/**
* saves service response to file
*
* @param response
* @throws Exception
*/
private void saveFile(SOAPMessage msg, String filename) throws Exception {
if( msg != null ) {
if(StringUtils.isEmpty(wsresponsefile)) {
wsresponsefile = "testResponse.xml";
}
System.out.println("Saving service response: " + filename);
FileOutputStream fos = null;
try {
fos = new FileOutputStream(filename);
msg.writeTo(fos);
}
catch(Exception e) {
e.printStackTrace();
}
finally {
IOUtils.close(fos);
}
}
}
private SOAPMessage createSOAPMsgFromFile(String filename) throws Exception {
if ( ! StringUtils.isEmpty(filename) ) {
System.out.println("Loading request payload: " + filename);
FileInputStream fis = null;
try {
fis = new FileInputStream(filename);
return MessageFactory.newInstance().createMessage(null, fis);
}
catch (Exception e) {
e.printStackTrace();
}
finally {
IOUtils.close(fis);
}
}
return null;
}
public static void main(String[] a) throws Exception {
new SoapClient().testWebService();
}
}
{code}
SOAP request --------------
{code}
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<sc:getPersonRequest xmlns:sc="http://www.t50.com/portable"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.t50.com/portable GetPerson.xsd ">
<person>
<firstName>john</firstName>
<lastName>wang</lastName>
<age>86</age>
</person>
</sc:getPersonRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
{code}
SOAP response --------------
{code}
<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:getPersonResponse xmlns:ns2="http://www.t50.com/portable">
<person>
<firstName>john</firstName>
<lastName>wang</lastName>
<age>30001</age>
</person>
</ns2:getPersonResponse>
</S:Body>
</S:Envelope>
{code}
- 16:48
- 浏览 (68)
- 评论 (0)
- 分类: Web Service
- 相关推荐
发表评论
- 浏览: 7374 次
- 性别:

- 来自: 苏州

- 详细资料
搜索本博客
我的相册
共 9 张
最近加入圈子
最新评论
-
公司要求实时监控服务器, ...
fxbird 写道kakaluyi 写道看来大家很少需要做这种实时监控,或者ja ...
-- by kakaluyi -
公司要求实时监控服务器, ...
还是尽量的要开源的 一是减少代码量二是更稳定更可靠三是更易于升级和扩展
-- by cuiyi.crazy -
公司要求实时监控服务器, ...
kakaluyi 写道看来大家很少需要做这种实时监控,或者javaeye大牛真的 ...
-- by fxbird -
公司要求实时监控服务器, ...
应该建议公司领导买一个网管软件,一个好的网管软件都能干这事!
-- by yimlin -
公司要求实时监控服务器, ...
kakaluyi 写道回楼上: 因为网管就只有很少的几个人会对服务器进行轮询监控 ...
-- by 土匪一份子






评论排行榜