Spoon是开源kettle的pentaho工具中data integration工具。
1. 新建转换,添加SOAP请求的"Modified Java Script Value"Step。
SOAP请求 :
//Script here var request=new XML(); request = <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:test="http://test.cxf.com/"> <soapenv:Header/> <soapenv:Body> <test:addUser> <!--Optional:--> <arg0>?</arg0> <!--Optional:--> <arg1>?</arg1> </test:addUser> </soapenv:Body> </soapenv:Envelope>; request = request.toXMLString();将request输出。
2. 添加"HTTP Post"Step
URL中添加"http://1.1.1.1:1234/user?wsdl"
入参"Request entity field"中选择"request"(是SOAP请求步骤中输出的参数)
返回"Result fieldname"中填写"result"(返回参数名称可自己命名)
3. 添加SOAP相应的"Modified Java Script Value"Step。
SOAP相应:
//Script here // 去除<xml ...> result = result.replace(/^<\?xml\s+version\s*=\s*(["'])[^\1]+\1[^?]*\?>/,""); // 将result转换为XML对象。 var response = new XML(result); // 也可以使用下面的方式 // var response = eval(result); var soap = response.namespace(); // 也可以 //var soap = new Namespace("http://schemas.xmlsoap.org/soap/envelope/"); var ws = response.*.*.namespace(); //也可以 //var ws = new Namespace("http://test.cxf.com/"); default xml namespace = ws; // 获取addUserResponse节点内容 var responseBody = response.soap::Body.addUserResponse; // 获取return节点的值 var returns = eval(responseBody.toXMLString())['return']; Alert(returns);
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。