c++学习之路------------------------vs2005生成的WebService.h和gjl.h

结合c++学习之路------------------------WebService的main代码

WebService.h

#include "gjl.h"
#include "add.h"

gjl.h    需修改相应url

#pragma once


#using <mscorlib.dll>
#using <System.dll>
#using <System.Xml.dll>
#using <System.Web.Services.dll>
#using <System.EnterpriseServices.dll>


using namespace System::Security::Permissions;
[assembly:SecurityPermissionAttribute(SecurityAction::RequestMinimum, SkipVerification=false)];
// 
// 此源代码由 wsdl 自动生成, Version=2.0.50727.42。
// 
namespace gjl {
    using namespace System::Diagnostics;
    using namespace System::Web::Services;
    using namespace System::ComponentModel;
    using namespace System::Web::Services::Protocols;
    using namespace System;
    using namespace System::Xml::Serialization;
    
    using namespace System;
    ref class Service;
    ref class HelloWorldCompletedEventArgs;
    ref class AddCompletedEventArgs;
    ref class ShowCompletedEventArgs;
    
    
    /// <remarks/>
    [System::CodeDom::Compiler::GeneratedCodeAttribute(L"wsdl", L"2.0.50727.42")]
    public delegate System::Void HelloWorldCompletedEventHandler(System::Object^  sender, gjl::HelloWorldCompletedEventArgs^  e);
    
    /// <remarks/>
    [System::CodeDom::Compiler::GeneratedCodeAttribute(L"wsdl", L"2.0.50727.42")]
    public delegate System::Void AddCompletedEventHandler(System::Object^  sender, gjl::AddCompletedEventArgs^  e);
    
    /// <remarks/>
    [System::CodeDom::Compiler::GeneratedCodeAttribute(L"wsdl", L"2.0.50727.42")]
    public delegate System::Void ShowCompletedEventHandler(System::Object^  sender, gjl::ShowCompletedEventArgs^  e);
    
    /// <remarks/>
    [System::CodeDom::Compiler::GeneratedCodeAttribute(L"wsdl", L"2.0.50727.42"), 
    System::Diagnostics::DebuggerStepThroughAttribute, 
    System::ComponentModel::DesignerCategoryAttribute(L"code"), 
    System::Web::Services::WebServiceBindingAttribute(Name=L"ServiceSoap", Namespace=L"http://tempuri.org/")]
    public ref class Service : public System::Web::Services::Protocols::SoapHttpClientProtocol {
        
        private: System::Threading::SendOrPostCallback^  HelloWorldOperationCompleted;
        
        private: System::Threading::SendOrPostCallback^  AddOperationCompleted;
        
        private: System::Threading::SendOrPostCallback^  ShowOperationCompleted;
        
        /// <remarks/>
        public: event gjl::HelloWorldCompletedEventHandler^  HelloWorldCompleted;
        
        /// <remarks/>
        public: event gjl::AddCompletedEventHandler^  AddCompleted;
        
        /// <remarks/>
        public: event gjl::ShowCompletedEventHandler^  ShowCompleted;
        
        /// <remarks/>
        public: Service();
        /// <remarks/>
        public: [System::Web::Services::Protocols::SoapDocumentMethodAttribute(L"http://tempuri.org/HelloWorld", RequestNamespace=L"http://tempuri.org/", 
            ResponseNamespace=L"http://tempuri.org/", Use=System::Web::Services::Description::SoapBindingUse::Literal, ParameterStyle=System::Web::Services::Protocols::SoapParameterStyle::Wrapped)]
        System::String^  HelloWorld();
        
        /// <remarks/>
        public: System::IAsyncResult^  BeginHelloWorld(System::AsyncCallback^  callback, System::Object^  asyncState);
        
        /// <remarks/>
        public: System::String^  EndHelloWorld(System::IAsyncResult^  asyncResult);
        
        /// <remarks/>
        public: System::Void HelloWorldAsync();
        
        /// <remarks/>
        public: System::Void HelloWorldAsync(System::Object^  userState);
        
        private: System::Void OnHelloWorldOperationCompleted(System::Object^  arg);
        
        /// <remarks/>
        public: [System::Web::Services::Protocols::SoapDocumentMethodAttribute(L"http://tempuri.org/Add", RequestNamespace=L"http://tempuri.org/", 
            ResponseNamespace=L"http://tempuri.org/", Use=System::Web::Services::Description::SoapBindingUse::Literal, ParameterStyle=System::Web::Services::Protocols::SoapParameterStyle::Wrapped)]
        System::Int32 Add(System::Int32 a, System::Int32 b);
        
        /// <remarks/>
        public: System::IAsyncResult^  BeginAdd(System::Int32 a, System::Int32 b, System::AsyncCallback^  callback, System::Object^  asyncState);
        
        /// <remarks/>
        public: System::Int32 EndAdd(System::IAsyncResult^  asyncResult);
        
        /// <remarks/>
        public: System::Void AddAsync(System::Int32 a, System::Int32 b);
        
        /// <remarks/>
        public: System::Void AddAsync(System::Int32 a, System::Int32 b, System::Object^  userState);
        
        private: System::Void OnAddOperationCompleted(System::Object^  arg);
        
        /// <remarks/>
        public: [System::Web::Services::Protocols::SoapDocumentMethodAttribute(L"http://tempuri.org/Show", RequestNamespace=L"http://tempuri.org/", 
            ResponseNamespace=L"http://tempuri.org/", Use=System::Web::Services::Description::SoapBindingUse::Literal, ParameterStyle=System::Web::Services::Protocols::SoapParameterStyle::Wrapped)]
        System::String^  Show(System::String^  yourname);
        
        /// <remarks/>
        public: System::IAsyncResult^  BeginShow(System::String^  yourname, System::AsyncCallback^  callback, System::Object^  asyncState);
        
        /// <remarks/>
        public: System::String^  EndShow(System::IAsyncResult^  asyncResult);
        
        /// <remarks/>
        public: System::Void ShowAsync(System::String^  yourname);
        
        /// <remarks/>
        public: System::Void ShowAsync(System::String^  yourname, System::Object^  userState);
        
        private: System::Void OnShowOperationCompleted(System::Object^  arg);
        
        /// <remarks/>
        public: System::Void CancelAsync(System::Object^  userState) new;
    };
    
    /// <remarks/>
    [System::CodeDom::Compiler::GeneratedCodeAttribute(L"wsdl", L"2.0.50727.42"), 
    System::Diagnostics::DebuggerStepThroughAttribute, 
    System::ComponentModel::DesignerCategoryAttribute(L"code")]
    public ref class HelloWorldCompletedEventArgs : public System::ComponentModel::AsyncCompletedEventArgs {
        
        private: cli::array< System::Object^  >^  results;
        
        internal: HelloWorldCompletedEventArgs(cli::array< System::Object^  >^  results, System::Exception^  exception, System::Boolean cancelled, 
                    System::Object^  userState);
        /// <remarks/>
        public:  property System::String^  Result {
            System::String^  get();
        }
    };
    
    /// <remarks/>
    [System::CodeDom::Compiler::GeneratedCodeAttribute(L"wsdl", L"2.0.50727.42"), 
    System::Diagnostics::DebuggerStepThroughAttribute, 
    System::ComponentModel::DesignerCategoryAttribute(L"code")]
    public ref class AddCompletedEventArgs : public System::ComponentModel::AsyncCompletedEventArgs {
        
        private: cli::array< System::Object^  >^  results;
        
        internal: AddCompletedEventArgs(cli::array< System::Object^  >^  results, System::Exception^  exception, System::Boolean cancelled, 
                    System::Object^  userState);
        /// <remarks/>
        public:  property System::Int32 Result {
            System::Int32 get();
        }
    };
    
    /// <remarks/>
    [System::CodeDom::Compiler::GeneratedCodeAttribute(L"wsdl", L"2.0.50727.42"), 
    System::Diagnostics::DebuggerStepThroughAttribute, 
    System::ComponentModel::DesignerCategoryAttribute(L"code")]
    public ref class ShowCompletedEventArgs : public System::ComponentModel::AsyncCompletedEventArgs {
        
        private: cli::array< System::Object^  >^  results;
        
        internal: ShowCompletedEventArgs(cli::array< System::Object^  >^  results, System::Exception^  exception, System::Boolean cancelled, 
                    System::Object^  userState);
        /// <remarks/>
        public:  property System::String^  Result {
            System::String^  get();
        }
    };
}
namespace gjl {
    
    
    inline Service::Service() {
        this->Url = L"http://localhost:1409/ex3/Service.asmx";
    }
    
    inline System::String^  Service::HelloWorld() {
        cli::array< System::Object^  >^  results = this->Invoke(L"HelloWorld", gcnew cli::array< System::Object^  >(0));
        return (cli::safe_cast<System::String^  >(results[0]));
    }
    
    inline System::IAsyncResult^  Service::BeginHelloWorld(System::AsyncCallback^  callback, System::Object^  asyncState) {
        return this->BeginInvoke(L"HelloWorld", gcnew cli::array< System::Object^  >(0), callback, asyncState);
    }
    
    inline System::String^  Service::EndHelloWorld(System::IAsyncResult^  asyncResult) {
        cli::array< System::Object^  >^  results = this->EndInvoke(asyncResult);
        return (cli::safe_cast<System::String^  >(results[0]));
    }
    
    inline System::Void Service::HelloWorldAsync() {
        this->HelloWorldAsync(nullptr);
    }
    
    inline System::Void Service::HelloWorldAsync(System::Object^  userState) {
        if (this->HelloWorldOperationCompleted == nullptr) {
            this->HelloWorldOperationCompleted = gcnew System::Threading::SendOrPostCallback(this, &gjl::Service::OnHelloWorldOperationCompleted);
        }
        this->InvokeAsync(L"HelloWorld", gcnew cli::array< System::Object^  >(0), this->HelloWorldOperationCompleted, userState);
    }
    
    inline System::Void Service::OnHelloWorldOperationCompleted(System::Object^  arg) {
        {
            System::Web::Services::Protocols::InvokeCompletedEventArgs^  invokeArgs = (cli::safe_cast<System::Web::Services::Protocols::InvokeCompletedEventArgs^  >(arg));
            this->HelloWorldCompleted(this, (gcnew gjl::HelloWorldCompletedEventArgs(invokeArgs->Results, invokeArgs->Error, 
                    invokeArgs->Cancelled, invokeArgs->UserState)));
        }
    }
    
    inline System::Int32 Service::Add(System::Int32 a, System::Int32 b) {
        cli::array< System::Object^  >^  results = this->Invoke(L"Add", gcnew cli::array< System::Object^  >(2) {a, b});
        return (*cli::safe_cast<System::Int32^>(results[0]));
    }
    
    inline System::IAsyncResult^  Service::BeginAdd(System::Int32 a, System::Int32 b, System::AsyncCallback^  callback, System::Object^  asyncState) {
        return this->BeginInvoke(L"Add", gcnew cli::array< System::Object^  >(2) {a, b}, callback, asyncState);
    }
    
    inline System::Int32 Service::EndAdd(System::IAsyncResult^  asyncResult) {
        cli::array< System::Object^  >^  results = this->EndInvoke(asyncResult);
        return (*cli::safe_cast<System::Int32^>(results[0]));
    }
    
    inline System::Void Service::AddAsync(System::Int32 a, System::Int32 b) {
        this->AddAsync(a, b, nullptr);
    }
    
    inline System::Void Service::AddAsync(System::Int32 a, System::Int32 b, System::Object^  userState) {
        if (this->AddOperationCompleted == nullptr) {
            this->AddOperationCompleted = gcnew System::Threading::SendOrPostCallback(this, &gjl::Service::OnAddOperationCompleted);
        }
        this->InvokeAsync(L"Add", gcnew cli::array< System::Object^  >(2) {a, b}, this->AddOperationCompleted, userState);
    }
    
    inline System::Void Service::OnAddOperationCompleted(System::Object^  arg) {
        {
            System::Web::Services::Protocols::InvokeCompletedEventArgs^  invokeArgs = (cli::safe_cast<System::Web::Services::Protocols::InvokeCompletedEventArgs^  >(arg));
            this->AddCompleted(this, (gcnew gjl::AddCompletedEventArgs(invokeArgs->Results, invokeArgs->Error, invokeArgs->Cancelled, 
                    invokeArgs->UserState)));
        }
    }
    
    inline System::String^  Service::Show(System::String^  yourname) {
        cli::array< System::Object^  >^  results = this->Invoke(L"Show", gcnew cli::array< System::Object^  >(1) {yourname});
        return (cli::safe_cast<System::String^  >(results[0]));
    }
    
    inline System::IAsyncResult^  Service::BeginShow(System::String^  yourname, System::AsyncCallback^  callback, System::Object^  asyncState) {
        return this->BeginInvoke(L"Show", gcnew cli::array< System::Object^  >(1) {yourname}, callback, asyncState);
    }
    
    inline System::String^  Service::EndShow(System::IAsyncResult^  asyncResult) {
        cli::array< System::Object^  >^  results = this->EndInvoke(asyncResult);
        return (cli::safe_cast<System::String^  >(results[0]));
    }
    
    inline System::Void Service::ShowAsync(System::String^  yourname) {
        this->ShowAsync(yourname, nullptr);
    }
    
    inline System::Void Service::ShowAsync(System::String^  yourname, System::Object^  userState) {
        if (this->ShowOperationCompleted == nullptr) {
            this->ShowOperationCompleted = gcnew System::Threading::SendOrPostCallback(this, &gjl::Service::OnShowOperationCompleted);
        }
        this->InvokeAsync(L"Show", gcnew cli::array< System::Object^  >(1) {yourname}, this->ShowOperationCompleted, userState);
    }
    
    inline System::Void Service::OnShowOperationCompleted(System::Object^  arg) {
        {
            System::Web::Services::Protocols::InvokeCompletedEventArgs^  invokeArgs = (cli::safe_cast<System::Web::Services::Protocols::InvokeCompletedEventArgs^  >(arg));
            this->ShowCompleted(this, (gcnew gjl::ShowCompletedEventArgs(invokeArgs->Results, invokeArgs->Error, invokeArgs->Cancelled, 
                    invokeArgs->UserState)));
        }
    }
    
    inline System::Void Service::CancelAsync(System::Object^  userState) {
        __super::CancelAsync(userState);
    }
    
    
    inline HelloWorldCompletedEventArgs::HelloWorldCompletedEventArgs(cli::array< System::Object^  >^  results, System::Exception^  exception, 
                System::Boolean cancelled, System::Object^  userState) : 
            System::ComponentModel::AsyncCompletedEventArgs(exception, cancelled, userState) {
        this->results = results;
    }
    
    inline System::String^  HelloWorldCompletedEventArgs::Result::get() {
        this->RaiseExceptionIfNecessary();
        return (cli::safe_cast<System::String^  >(this->results[0]));
    }
    
    
    inline AddCompletedEventArgs::AddCompletedEventArgs(cli::array< System::Object^  >^  results, System::Exception^  exception, 
                System::Boolean cancelled, System::Object^  userState) : 
            System::ComponentModel::AsyncCompletedEventArgs(exception, cancelled, userState) {
        this->results = results;
    }
    
    inline System::Int32 AddCompletedEventArgs::Result::get() {
        this->RaiseExceptionIfNecessary();
        return (*cli::safe_cast<System::Int32^>(this->results[0]));
    }
    
    
    inline ShowCompletedEventArgs::ShowCompletedEventArgs(cli::array< System::Object^  >^  results, System::Exception^  exception, 
                System::Boolean cancelled, System::Object^  userState) : 
            System::ComponentModel::AsyncCompletedEventArgs(exception, cancelled, userState) {
        this->results = results;
    }
    
    inline System::String^  ShowCompletedEventArgs::Result::get() {
        this->RaiseExceptionIfNecessary();
        return (cli::safe_cast<System::String^  >(this->results[0]));
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

g710710

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值