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 ...
随机推荐
- 正向代理 & 反向代理 & 透明代理
正向代理(Forward Proxy) 概述 一般情况下,如果没有特别说明,代理技术默认说的是正向代理技术.关于正向代理的概念如下: 正 向代理(forward)是一个位于客户端[用户A]和原始服务器 ...
- Zookeeper运维常用四字命令
Zookeeper运维常用四字命令 echo stat|nc 127.0.0.1 2181 查看哪个节点被选择作为follower或者leader 使用echo ruok|nc 127.0.0.1 2 ...
- AdaptIS: Adaptive Instance Selection Network
AdaptIS: Adaptive Instance Selection Network 2019-09-19 12:58:07 Paper: https://arxiv.org/pdf/1909.0 ...
- IDEA版本控制忽略文件或目录
写在前面 废话不多说了, 新创建了个helloworld, 见图: 这谁受得了啊 修改配置 在上图红框内部的后面添加: *.iml;*.idea;*.gitignore;*.sh;*.classpat ...
- Java算法 -- 桶排序
桶排序(Bucket sort)或所谓的箱排序,是一个排序算法,工作的原理是将数组分到有限数量的桶里.每个桶再个别排序(有可能再使用别的排序算法或是以递归方式继续使用桶排序进行排序).桶排序是鸽巢排序 ...
- 图像处理软件ImageJ
ImageJ是一个基于java的公共的图像处理软件,它是由National Institutes of Health开发的.可运行于Microsoft Windows,Mac OS,Mac OS X, ...
- 分享一下我的个人微信小程序
分享一下我的个人微信小程序 1.有我平时整理的一些小程序相关的技术,供大家参考. 2.有几个好玩的例子 有问题可以一起参考
- Influx Sql系列教程六:insert 修改数据
在influxdb中没有专门的修改数据的update语句,对于influxdb而言,如果想修改数据,还是得使用我们前面的说到的insert来实现,那么怎么判断一条insert语句是插入还是修改呢? 1 ...
- php_mvc实现步骤八
shop34-10-框架类 框架类(框架初始化类) 将原来入口文件中功能,放在该类中完成,入口文件变得简单,轻量! 将入口文件中的各个功能,由框架类的各个方法,完成: 为了简单化,使用纯静态的类.(看 ...
- py库:pdfminer3k、docx。(PDFf转word)
安装pdfminer模块: pip install pdfminer3k 安装docx模块: https://www.lfd.uci.edu/~gohlke/pythonlibs/ 下载 pytho ...