加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

worklight中adapter(webservice)

发布时间:2020-12-16 23:51:33 所属栏目:安全 来源:网络整理
导读:找个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

找个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;
}

这样就可以获取到接口里的数据了。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读