找个webservice的接口,如:http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl
用soupUI打开,使用第一个接口,如:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://WebXml.com.cn/">
<soapenv:Header/>
<soapenv:Body>
<web:getMobileCodeInfo>
<!--Optional:-->
<web:mobileCode>?</web:mobileCode>
<!--Optional:-->
<web:userID>?</web:userID>
</web:getMobileCodeInfo>
</soapenv:Body>
</soapenv:Envelope>
?部分为填入的参数。
写test.xml,如:
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed Materials - Property of IBM
5725-G92 (C) Copyright IBM Corp. 2011, 2013. All Rights Reserved.
US Government Users Restricted Rights - Use, duplication or
disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
-->
<wl:adapter name="test"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wl="http://www.worklight.com/integration"
xmlns:http="http://www.worklight.com/integration/http">
<displayName>test</displayName>
<description>test</description>
<connectivity>
<connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
<protocol>
http</protocol>
<domain>
webservice.webxml.com.cn</domain>
<port>
80</port>
<!-- Following properties used by adapter's key manager for choosing specific certificate from key store
<sslCertificateAlias></sslCertificateAlias>
<sslCertificatePassword></sslCertificatePassword>
-->
</connectionPolicy>
<loadConstraints maxConcurrentConnectionsPerNode="2" />
</connectivity>
<procedure name="getStories"/>
</wl:adapter>
在test-impl.js中,如:
/**
* @param interest
* must be one of the following: world, africa, sport, technology, ...
* (The list can be found in http://edition.cnn.com/services/rss/)
* @returns json list of items
*/
function getStories() {
//这部分与soupUI看的是相同的
var contentRequest = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:web=\"http://WebXml.com.cn/\">";
contentRequest += "<soapenv:Header/>";
contentRequest += "<soapenv:Body>";
contentRequest += "<web:getMobileCodeInfo>";
contentRequest += "<web:mobileCode>0</web:mobileCode>";
contentRequest += "<web:userID>0</web:userID>";
contentRequest += "</web:getMobileCodeInfo>";
contentRequest += "</soapenv:Body>";
contentRequest += "</soapenv:Envelope>";
var input = {
method : 'get',
returnedContentType : 'xml',
path : "/WebServices/MobileCodeWS.asmx?wsdl",
body : {
content : contentRequest.toString(),
contentType : 'text/xml; charset=utf-8'
},
};
var baseDatares=WL.Server.invokeHttp(input);
return baseDatares;
}
这样就可以获取到接口里的数据了。