ColdFusion 编写WebService 示例
1.开发 Web Services,编写cfcdemo.cfc组件,代码如下:
<cfcomponent style ="document"
namespace = "http://www.mycompany.com/"
serviceportname = "RestrictedEmpInfo"
porttypename = "RestrictedEmpInfo"
bindingname = "myns:RestrictedEmpInfo"
displayname = "RestrictedEmpInfo"
hint = "RestrictedEmpInfo">
<cffunction name = "getEname" access = "remote" returntype="xml" output="no" >
<cfargument name = "dname" type = "string" required = "false">
<cfargument name = "loc" type = "string" required = "false">
<cfquery name = "dt" datasource = "scott">
select * from dept where
<cfif arguments.dname neq "">
dname = #arguments.dname#
</cfif>
</cfquery>
<cfxml variable="Books">
<XML>
<cfoutput query="rs">
<book>
<bname>#deptno#</bname>
<isbn>#dname#</isbn>
<writer>#loc#</writer>
</book>
</cfoutput>
</XML>
</cfxml>
<cfreturn Books>
</cffunction>
</cfcomponent>
<!---
ColdFusion开发 Web Services,只需要在ColdFusion组件(.cfc文件)中,
把需要作为 Web Services 的method的access类型定义为remote就可以了(access="remote")。
--->
2.测试一下,访问这个cfc组件,注意URL路径后边要加上 ?wsdl 。
eg:http://localhost/mysys/cfcdemo.cfc?wsdl
显示效果如下:

3.开发测试页面,编写webservice.cfm程序调用①开发的 Web service ,代码如下:
<cfset sWebServiceUrl = "http://localhost/cfcdemo.cfc?wsdl">
<cfinvoke webservice="#sWebServiceUrl#"
component = "cfcdemo"
method = "getdept"
returnVariable = "dept">
<cfinvokeargument name = "dname" value="10"/>
<!--- 访问参数,与参数值,对应.cfc中的 cfargument --->
<cfinvokeargument name = "loc" value=""/>
</cfinvoke>
<cfdump var="#dept#">
4.说明:调用 Web Service 时,webservice.cfm部分和cfcdemo.cfc?wsdl对应如下:
<cffunction></cffunction>
<!--- cfc组件中的方法,在cfcomponent中可以有多个 --->
method -- 对应cfc组件中的方法,<cffunction>标签内name属性的值
timeout -- 设置请求超时秒数
returnVariable -- 自定义的变量,里边存放的是 Web Service 返回的值
<!---传递参数--->
<cfinvokeargument name="empno" value="7788"/> --
<!---接收参数--->
<cfargument name="empno" type="string" required="true">
<cfoutput>#dept#</cfoutput> -- 输出 Web Service
<!--- 注意返回类型一定要与 returntype 对应--->
本文日期2018-11-08
ColdFusion 编写WebService 示例的更多相关文章
- ArcEngine编写WebService
开发环境:Windows7旗舰版64bit.VisualStudio2008 With SP1.ArcEngine10.0.NetFrameWork4.0.IIS7和C#开发语言. 背景:ArcEng ...
- Selenium2学习-002-Selenium2 Web 元素定位及 XPath 编写演示示例
此文主要对 Selenium2 的 Web 元素定位及 XPath 编写示例,敬请各位亲们参阅,共同探讨.若有不足之处,敬请各位大神指正,不胜感激! 通过 Firefox(火狐)浏览器的插件 Fire ...
- 使用RSA进行信息加密解密的WebService示例
使用RSA进行信息加密解密的WebService示例 按:以下文字涉及RSA对WebService传递的数据的加密解密,如果您已经熟知RSA或是有其它更好的方法请不要往下看以免浪费时间. WebSer ...
- Delphi编写WebService体会
源:Delphi编写WebService体会 Dispatch: 派遣,分派 Invoke: 调用 Invokable: 可调用接口 TReomtable: WebService中自定义类都是继承自该 ...
- delphi7编写客户端调用java服务器端webservice示例
1. 首先取得java-webservice服务器端地址.我的是:http://localhost:8080/mywebservice/services/mywebservice?wsdl 2. 然后 ...
- AXIS2远程调用WebService示例(Eclipse+AXIS)
转自:http://www.cnblogs.com/lanxuezaipiao/archive/2013/05/10/3071584.html 我们将Web Service发布在Tomcat或者其他应 ...
- Httpclient远程调用WebService示例(Eclipse+httpclient)
package cn.com.taiji.pos.httpserver; import java.io.BufferedInputStream;import java.io.ByteArrayOutp ...
- LR编写webservice协议接口
转自:http://lovesoo.org/use-loadrunner-call-webservice-interface-testing-optimization-summary.html 本文主 ...
- 使用Axis2编写webservice客户端,服务端
1.编写客户端 Axis2开发WebService客户端 的3种方式 [参考帖子] http://blog.csdn.net/wangjinwei6912/article/details/851259 ...
随机推荐
- 定制比特币btc地址address
https://99bitcoins.com/how-to-get-a-custom-bitcoin-address/ https://en.bitcoin.it/wiki/Vanitygen htt ...
- 工具系列 | VScode Remote 远程开发与调试(告别SSH)
简介 最近VScode发布了远程编程与调试的插件Remote Development,使用这个插件可以在很多情况下代替vim直接远程修改与调试服务器上的代码,同时具备代码高亮与补全功能,就和在本地使用 ...
- Python开发人员指南
本指南是一个全面的资源贡献 给Python的 -为新的和经验丰富的贡献者.这是 保持由维护的Python同一社区.我们欢迎您对Python的贡献! 快速参考 这是设置和添加补丁所需的基本步骤.了解基础 ...
- Windows10环境下 Nginx+ffmpeg自搭服务器制作RTMP直播流
Windows10环境下 Nginx+ffmpeg自搭服务器制作RTMP直播流学习笔记 所需条件: nginx-rtmp-module(带rtmp模块) ,链接:https://link.jiansh ...
- node 报错 env: node\r: No such file or directory
最近在编写一个命令行工具.使用 npm link 时可以正常运行.但是 ctrl+s 保存后, 再运行则报错 env: node\r: No such file or directory ,需要再 n ...
- postgrelsql 的 wm_concat : string_agg
string_agg,array_agg 这两个函数的功能大同小异,只不过合并数据的类型不同 array_agg(expression) 把表达式变成一个数组 一般配合 array_to_string ...
- function的json对象转换字符串与字符串转换为对象的方法
// json对象转换成字符串var str = JSON.stringify(json, function(key, val) { if (typeof val === 'function') { ...
- POJ 1014 Dividing(入门例题一)
Time Limit: 1000MS Memory Limit: 10000K Total Submissions: Accepted: Description Marsha and Bill own ...
- 13 Spring 的事务控制
1.事务的概念 理解事务之前,先讲一个你日常生活中最常干的事:取钱. 比如你去ATM机取1000块钱,大体有两个步骤:首先输入密码金额,银行卡扣掉1000元钱:然后ATM出1000元钱.这两个步骤必 ...
- 【转帖】从原理到应用,Elasticsearch详解
从原理到应用,Elasticsearch详解 https://segmentfault.com/a/1190000020022504 elasticsearch 2.1k 次阅读 · 读完需要 4 ...