📄 1054.html
字号:
<TD background="images/bgline.gif" tppabs="http://www.linuxhero.com/docs/images/bgline.gif"><IMG height=22
src="images/header_r2_c1.gif" tppabs="http://www.linuxhero.com/docs/images/header_r2_c1.gif" width=296 border=0
name=header_r2_c1></TD>
<TD background="images/bgline.gif" tppabs="http://www.linuxhero.com/docs/images/bgline.gif" colSpan=5>
<DIV align=right><FONT class=normalfont>当前位置:
<A href="index.html" tppabs="http://www.linuxhero.com/docs/index.html">本站首页</A>
<font color="#FF6699">>></font>
<A href="type14.html" tppabs="http://www.linuxhero.com/docs/type14.html">编程技术</A> | <A href="copyright.html" tppabs="http://www.linuxhero.com/docs/copyright.html">版权说明</A></font></DIV>
</TD>
<TD><IMG height=22 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=1
border=0></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=10 cellPadding=0 width="100%" bgColor=#ffffff
border=0>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=3 width="100%" border=0>
<TR>
<TD vAlign=top align=middle width="60%">
<TABLE cellSpacing=0 cellPadding=0 width="100%"
background="images/back.gif" tppabs="http://www.linuxhero.com/docs/images/back.gif" border=0>
<TBODY>
<TR>
<TD vAlign=top width="80%">
<DIV align=center>
<FORM action="search.html" tppabs="http://www.linuxhero.com/docs/search.html" method=get>
</FORM>
<TABLE cellSpacing=0 cellPadding=0 width="95%"
border=0><TBODY>
<TR>
<TD background="images/bgi.gif" tppabs="http://www.linuxhero.com/docs/images/bgi.gif"
height=30></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=3 width="95%"
align=center border=0>
<TBODY>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=3 width="100%"
border=0>
<TBODY>
<TR>
<TD vAlign=top>
<p><FONT class=normalfont><B><font color=blue>websphere新建C/C++客户机</font></B></FONT><BR><FONT class=smallfont color=#ff9900>2004-04-23 15:18 pm</FONT><BR><FONT class=normalfont>作者:Nay Lin<br>来自:Linux知识宝库<br>联系方式:无名<br><br>使用WebSphere Studio Application Developer、gSOAP和Dev-C++为WebSphere Web服务新建一个C/C++客户机<br>
内容<br>
引言<br>
下载并安装 gSOAP 工具<br>
安装 gSOAP WSDL importer 工具<br>
准备一个输入 WSDL 文件<br>
生成 C/C++ 组件和一个客户机<br>
定制主要的 C/C++ 客户机<br>
生成 Windows 控制台应用程序或 DLL<br>
结束语<br>
<br>
Nay Lin<br>
顾问软件工程师,WebSphere Enablement Team<br>
IBM Customer Solutions Center,加利福尼亚圣地亚哥<br>
2003 年 1 月<br>
<br>
? Copyright International Business Machines Corporation 2003. All rights reserved.<br>
引言<br>
<br>
WebSphere? Studio Application Developer(以下称为 Application Developer)为快速从现有 J2EE 组件构建 SOAP/XML Web 提供向导,例如从会话 EJB 和 Java? bean 组件来构建。Application Developer 能为任何 Java 客户机或 WSDL 文件生成一个 Java 客户机代理,只要这些文件能被其它供应商用来构建 Web 服务客户机。<br>
<br>
某些情况下,您也许需要一个非 Java 客户机来使用 J2EE Web 服务。您可以使用 Microsoft? .NET 框架提供的 wsdl.exe 工具来为 WebSphere Web 服务生成一个 C# 或 Jscript 客户机。或者,一些开放源代码工具能为在不同语言和操作系统中生成客户机提供便利。(这里有 SOAP 软件工具清单)。<br>
<br>
开放源代码工具之一的 gSOAP 提供一种独特的 SOAP/XML 到 C/C++ 语言绑定,以简化 C 或 C++ 中 SOAP/XML Web 服务和客户机的开发。gSOAP 工具包括一个 WSDL 生成器,用于为您的 Web 服务生成 Web 服务描述。WSDL importer 工具使 SOAP 客户机应用程序开发完全自动化。<br>
<br>
使用 Application Developer 和 gSOAP 编译器、C/C++ 和 Fortran 下的客户机(经由一个 Fortran 连接到 C 接口)以及 4GL 客户机,例如 PowerBuilder(通过一个 C++ DLL),就能通过 WebSphere Application Server 跨平台连接作为 Web 服务公开的 J2EE 应用程序。<br>
<br>
为相应的 J2EE Web 服务生成一个 C/C++ 客户机:<br>
<br>
1. 使用 Application Developer 生成 Web 服务及其 WSDL 文件,以公开一个 EJB 或 Java bean。<br>
2. 在分布式平台上的 WebSphere 4.0x/5.0 或 z/OS? 和 OS/390? 上的 WebSphere 4.01 上部署 Web 服务。<br>
3. 使用 gSOAP WSDL importer 工具生成一个 C/C++ 客户机应用程序或 DLL。本教程描述了如何运行第 3 步,假定第 1 步和第 2 步已完成。可在本页下方下载为 Web 服务而从 Application Developer 4.02 生成并导出的名为 HelloWorld.ear 的样本企业归档(enterprise archive,EAR)文件。关于第 1 步和第 2 步的详细情况,参见 Application Developer 的联机帮助或在相关信息中列出的关于使用 Application Developer 生成 Web 服务的教程和红皮书。<br>
<br>
下载并安装 gSOAP 工具<br>
<br>
进入 SourceForge 网站并(对于 Windows? 工作站)下载名为 soapcpp-win32-2.1.7.zip 的 ZIP 文件。将所有文件解压缩到安装盘(比如 C:)。如要测试 gSOAP 示例和 SSL,请按照 C:soapcpp-win32-2.1.7INSTALL.txt 里的说明。<br>
安装 gSOAP WSDL importer 工具<br>
<br>
1. 切换到 C:soapcpp-win32-2.1.7wsdlcpp 目录,阅读 readme.txt 中关于第 1 步的说明。<br>
2. 安装一个用于 Java 的 XML 解析器,例如 Apache Xerces 2.0.1(xercesImpl.jar 和 xmlParserAPIs.jar)或 Xerces 1.4.4(xerces.jar)。可根据需要改变类路径。WSDL 导入工具的 wsdlcpp.java 资源已为 Xerces DOM 解析器配置好了。如要使用另一个 Java DOM 解析器,请在 wsdlcpp.java 中修改 DOM 解析器类导入。<br>
3. 使用 javac wsdlcpp.java 命令编译 wsdlcpp。<br>
<br>
准备一个输入 WSDL 文件<br>
<br>
此工具并不支持 <import../> 标记。这个输入 WSDL 文件一定要是独立的(参见 C:soapcpp- win32-2.1.7wsdlcppREADME.txt 文件中 Limitations 下的说明)。Application Developer 或 Application Developer Integration Edition 为每个 Web 服务 EAR 生成两个名为 <wsname> 的 WSDL 文件(比如 <wsname>-service.wsdl 和 <wsname>-binding.wsdl)。第一个文件 <wsname>-service.wsdl 导入绑定的定义 <wsname>-binding.wsdl。要将它们合并到一个文件中:<br>
<br>
1. 复制 <wsname>-binding.wsdl 中 <definitions>...</definitions> 里的所有元素条目。<br>
2. 编辑 <wsname>-service.wsdl,将条目 <import ../> 用上面复制的内容覆盖。<br>
<br>
此处的示例是 Application Developer 为作为 Web 服务公开的 HellowWorld 会话 EJB 的 hello 方法而生成的两个 WSDL 文件:<br>
<br>
清单 1.HelloWorld-service.wsdl<br>
<br>
<definitions name="HelloWorldService"<br>
targetNamespace="http://localhost:8080/HelloWorldWebService/wsdl/HelloWorld-service.wsdl"<br>
xmlns="http://schemas.xmlsoap.org/wsdl/"<br>
xmlns:binding="http://www.helloworld.com/definitions/HelloWorldRemoteInterface"<br>
xmlns:soap=http://schemas.xmlsoap.org/wsdl/soap/<br>
xmlns:tns="http://localhost:8080/HelloWorldWebService/wsdl/HelloWorld-service.wsdl"><br>
<import location="http://localhost:8080/HelloWorldWebService/wsdl/HelloWorld-binding.wsdl"<br>
namespace="http://www.helloworld.com/definitions/HelloWorldRemoteInterface"/> <br>
<service name="HelloWorldService"><br>
<port binding="binding:HelloWorldBinding" name="HelloWorldPort"><br>
<soap:address location="http://localhost:8080/HelloWorldWebService/servlet/rpcrouter"/><br>
</port><br>
</service><br>
</definitions><br>
<br>
清单 2.HelloWorld-binding.wsdl<br>
<br>
<definitions name="HelloWorld-binding"<br>
targetNamespace="http://www.helloworld.com/definitions/HelloWorldRemoteInterface"<br>
xmlns="http://schemas.xmlsoap.org/wsdl/"<br>
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"<br>
xmlns:tns=http://www.helloworld.com/definitions/HelloWorldRemoteInterface<br>
xmlns:xsd="http://www.w3.org/2001/XMLSchema"><br>
<message name="helloRequest"><br>
<part name="str" type="xsd:string"/><br>
</message><br>
<message name="helloResponse"><br>
<part name="result" type="xsd:string"/><br>
</message><br>
<portType name="HelloWorld"><br>
<operation name="hello" parameterOrder="str"><br>
<input message="tns:helloRequest" name="helloRequest"/><br>
<output message="tns:helloResponse" name="helloResponse"/><br>
</operation><br>
</portType><br>
<binding name="HelloWorldBinding" type="tns:HelloWorld"><br>
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/><br>
<operation name="hello"><br>
<soap:operation soapAction="" style="rpc"/><br>
<input name="helloRequest"><br>
<soap:body<br>
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"<br>
namespace="http://tempuri.org/com.ibm.hello.ejb.HelloWorld" use="encoded"/><br>
</input><br>
<output name="helloResponse"><br>
<soap:body<br>
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"<br>
namespace="http://tempuri.org/com.ibm.hello.ejb.HelloWorld" use="encoded"/><br>
</output><br>
</operation><br>
</binding><br>
</definitions><br>
<br>
这是合并后的 HelloWorld-service.wsdl WSDL 文件样本:<br>
<br>
清单 3. HelloWorld-service.wsdl<br>
<br>
<definitions name="HelloWorldService"<br>
targetNamespace="http://localhost:8080/HelloWorldWebService/wsdl/HelloWorld-service.wsdl"<br>
xmlns="http://schemas.xmlsoap.org/wsdl/"<br>
xmlns:binding="http://www.helloworld.com/definitions/HelloWorldRemoteInterface"<br>
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"<br>
xmlns:tns=http://localhost:8080/HelloWorldWebService/wsdl/HelloWorld-service.wsdl<br>
xmlns:xsd="http://www.w3.org/2001/XMLSchema"><br>
<message name="helloRequest"><br>
<part name="str" type="xsd:string"/><br>
</message><br>
<message name="helloResponse"><br>
<part name="result" type="xsd:string"/><br>
</message><br>
<portType name="HelloWorld"><br>
<operation name="hello" parameterOrder="str"><br>
<input message="tns:helloRequest" name="helloRequest"/><br>
<output message="tns:helloResponse" name="helloResponse"/><br>
</operation><br>
</portType><br>
<binding name="HelloWorldBinding" type="tns:HelloWorld"><br>
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/><br>
<operation name="hello"><br>
<soap:operation soapAction="" style="rpc"/><br>
<input name="helloRequest"><br>
<soap:body<br>
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"<br>
namespace=http://tempuri.org/com.ibm.hello.ejb.HelloWorld use="encoded"/><br>
</input><br>
<output name="helloResponse"><br>
<soap:body<br>
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"<br>
namespace="http://tempuri.org/com.ibm.hello.ejb.HelloWorld" use="encoded"/><br>
</output><br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -