使用非托管C++访问WEBSERVICE

使用WebServices methods using sproxy.exe provided by Visual Studio 2003 来生成代理. Visual Studio 2005同样带有sproxy.exe 这个工具。但是Visual Studio 2008就没有了. 原因应该是样的:

ATL Server: Visual C++ shared source software

Overview

 

The Visual C++ team is very pleased to announce our plans to release the source code of ATL Server as a shared source project on CodePlex in March 2007. With this release you will now have the opportunity to add all the features and functionality you want to ATL Server and you can even share your expertise and code directly with the ATL community. A main reason for releasing ATL Sever as shared source project is that many ATL Server users would like to see the functionality and services provided by ATL Server expanded and the Visual C++ team, while agreeing with the vision, cannot do justice to these requests while also working on a number of other libraries and tools that we ship. So rather than constrain the functionality of ATL Server  to fit within our product development cycle we know that by releasing the source code that the ATL Server community can move it forward at a greater pace. And we also know how much developers will enjoy cutting their teeth on such a large commercial codebase.

 

In a nutshell

 

ATL Server is a library of C++ classes that allow developers to build internet based applications. It provides much of the functionality required to build large scale internet sites, such as SOAP messaging, caching facilities, threading facilities, regular expression processing, management of session-state, performance monitoring, MIME support, integration with IIS and class for interacting with security and cryptographic infrastructure.

 

ATL Server will be released under the Microsoft Limited Permissive License (Ms-LPL)The basic terms of the license indicate:

  • You can read, edit, and redistribute the source code for either commercial or non-commercial purposes,
  • You are allowed to charge a licensing fee for the modified work
  • The use of the code is limited to the Windows platform.

 

For full and complete details of the licence, and to see if it meets your requirements, you should refer to the Ms-LPL license.

 

To be more specific

 

The following parts of ATL Server will part of the shared project:

 

  • Core ATL Server Framework classes in atlisapi.h, atlstencil.h, atlserr.h
  • Caching classes in atlcache.h
  • Cryptography classes in atlcrypt.h
  • HTML generation on server side and reading on client sides in atlhtml.h
  • Performance monitoring classes in atlperf.h
  • Extension management classes in atlextmgmt.h
  • Server and client side support for SOAP based Web services in atlsharedsvc.h, atlsoap.h
  • Session-state classes and interfaces in atlsession.h
  • MIME/SMTP support in atlmime.h and atlsmtpconnection.h
  • Regular Expression support from atlrx.h
  • Stream helpers in atlsoap.h and atlhtml.h
  • Many of the ATL Server tutorials, samples and help pages.

The following files will be part of the shared source project:

 

atlcache.h

atlcrypt.h

atlcrypt.inl

atlextmgmt.h

atlhtml.h

atlhttp.h

atlhttp.inl

atlisapi.h

atlmime.h

atlperf.h

atlperf.inl

atlrx.h

atlsession.h

atlserr.h

atlsharedsvc.h

atlsiface.h

atlsmtpconnection.h

atlsmtputil.h

atlsoap.h

atlsrv.rc

atlsrvres.h

atlstencil.h

res/dllmgr.srf

res/stencilmgr.srf

res/threadmgr.srf

 

Classes from atlenc.h for encoding and decoding of data and other utility functions and classes from atlutil.h are going to stay as part of ATL library and ship together with ATL in future releases of Visual Studio.

 

The source code to the following tools will also become part of the shared source project:

  The Visual C++ team hopes you will enjoy working on the ATL Server code and looks forward to the evolution of this library under the stewardship of the ATL Server community. If you have any question on this announcement then please do not hesitate to post a comment on the VC blog.

  • clstencil.exe - used in running Request Handler DLLs or SRF Files from the command line
  • sproxy.exe - used in generating proxy classes for SOAP based Web Service clients
  • vcdeploy.exe - used in deploying ATL Server projects to IIS

 

原因二:

Changes in the Visual C++ 2005 Libraries

 

The following sections discuss the updates and breaking changes to the libraries that are shipped with Visual C++.

 for Mixed Assemblies

Visual C++ 2005 supports the use of the Standard C++ Library and the ATL, MFC, and CRT libraries as mixed assemblies compiled with /clr. These mixed libraries allow you to use all of their existing functions when your code contains a mixture of native code and MSIL-based __clrcall code. For more information, see Mixed (Native and Managed) Assemblies.

Initialization of Mixed Assemblies

The library support changes in Visual C++ 2005 resolve the "loader lock" issues that applied to mixed DLLs in Visual C++ .NET and Visual C++ .NET 2003. However, there is still a restriction that your DllMain code must never access the CLR. For more information, see Mixed (Native and Managed) Assemblies.

Libraries not Supported by Pure Mode Compilation

In Visual C++ 2005, the ATL and MFC libraries are not supported by pure mode compilation (/clr:pure).

 

关于SProxy.exe工具的使用:

Introduction

Some days ago I faced the problem of calling the Webservices from VC++ 6.0 written in C#. The I searched on Google and found the article by Neil Yao that was very useful. Then I started to find the another way for calling the webservices. I came to know about the SPROXY.EXE. It is a command line tool that generates native C++ client code for accessing an XML Web service based on a WSDL description.

 

Soap Features:

Soap is a protocol which helps to communicate between the applications. Sending messages through internet. It is language independent, platform independent and is based on XML. Today the better way to communicate between is via Http request. Soap was brought in for this purpose.

Creating the Application:


First Step: Creating Web Service : Create the virtual directory and in that Create the Asp.net web Service project. Name it as MyWebService . In Implementation file that is MyWebService.asmx.cs file write the below code after the Component Designer Generated Code heading: [WebMethod] // Web method which will be exposed by the webservice. public string MyFun(String strMyName) { return "Hello " + strMyName; } Now build the WebService.

Second Step: Using SPROXY.EXE Go to the Visual studio 2003 command prompt there you type the following line: sproxy/wsdl Webservice_URL It will generate one header file which is native code. In this file the namespace name and Class name is same and you can find their signatures there.

Third Step: Creating MFC Application I am using Visual Studio 2003. Create New VC++ project then choose MFC Application after that you will see the MFC Application wizard. Click on Application type and Select dialog based application and Click finish. Now go to Resource view, place one button on it and name it as Call WebService and name of button as btnWebService. Double Click on the button you will see the message handler added for the button. You will See the OnbtnWebService() function being added. Now add the file created in Step Second in the Application. You will find the new class been created there. Now on click of OnbtnWebService() create the object of class and you can invoke the WebServices Methods. For this you have to include the header file and write the one more statement as:

Using namespace createdby_Sproxy;

 

我举个

>sproxy /wsdl http://10.0.0.102/WebServicesORama/QuoteService.asmx?wsdl
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值