Gsoap

简介: Gsoap

1.create 命令

wsdl2h -o a.h   up.WSDL
soapcpp2.exe  -C -x a.h


2.添加文件


soapTestSoap12Proxy.h
soapTestSoapProxy.h
soapH.h
soapStub.h
stdsoap2.h
soapClientLib.cpp
soapC.cpp
soapClient.cpp
stdsoap2.cpp
3.CSoap.h
/*/
Gsoap处理类
*/
#ifndef _CSOAP
#define _CSOAP
///
#pragma once
#include "stdafx.h"
#include "soapH.h"
#include "CRegister.h"
using namespace std;
class CSOAP
{
private:
 struct soap m_soap;
 SOAP_ENV__Header header;
public:
 CSOAP();
 ~CSOAP();
 bool InitSoap();
};
#endif
CSoap.cpp
#pragma once
#include "StdAfx.h"
#include "CSoap.h"
#include "string"
#include "FaceAttendanceCoreSoap.nsmap"
#include <afxwin.h>
#pragma warning(disable: 4996)
static std::string headerPass="Lucky";
static std::string headerName="Lucky";
wstring UTF8ToUnicode( const string& str   ){ int  len = 0; len =   str.length(); int  unicodeLen = ::MultiByteToWideChar(   CP_UTF8,              0,              str.c_str(),              -1,              NULL,            0   );   wchar_t *  pUnicode;   pUnicode =   new  wchar_t[unicodeLen+1];     memset(pUnicode,0,(unicodeLen+1)*sizeof(wchar_t));     ::MultiByteToWideChar(   CP_UTF8,           0,           str.c_str(),           -1,           (LPWSTR)pUnicode,         unicodeLen   );   wstring  rt;   rt = ( wchar_t*   )pUnicode; delete  pUnicode;   return    rt;  }
string   UnicodeToANSI( const wstring& str   ){ char*       pElementText; int    iTextLen; iTextLen = WideCharToMultiByte(   CP_ACP,           0,           str.c_str(),           -1,           NULL,           0,NULL,         NULL   ); pElementText = new char[iTextLen + 1]; memset( ( void*   )pElementText, 0, sizeof( char ) * ( iTextLen + 1 )   ); ::WideCharToMultiByte(   CP_ACP,           0,           str.c_str(),           -1,           pElementText,           iTextLen,           NULL,         NULL   ); string strText; strText = pElementText; delete[]   pElementText; return strText;}
wstring ANSIToUnicode( const string& str   ){ int  len = 0; len =   str.length(); int  unicodeLen = ::MultiByteToWideChar(   CP_ACP,              0,              str.c_str(),              -1,              NULL,            0   );   wchar_t *  pUnicode;   pUnicode =   new  wchar_t[unicodeLen+1];     memset(pUnicode,0,(unicodeLen+1)*sizeof(wchar_t));     ::MultiByteToWideChar(   CP_ACP,           0,           str.c_str(),           -1,           (LPWSTR)pUnicode,         unicodeLen   );   wstring  rt;   rt = ( wchar_t*   )pUnicode; delete  pUnicode;   return    rt;  }
string UnicodeToUTF8( const wstring& str   ){ char*       pElementText; int    iTextLen; iTextLen = WideCharToMultiByte(   CP_UTF8,           0,           str.c_str(),           -1,           NULL,           0,           NULL,         NULL   ); pElementText = new char[iTextLen + 1]; memset( ( void*   )pElementText, 0, sizeof( char ) * ( iTextLen + 1 )   ); ::WideCharToMultiByte(   CP_UTF8,           0,           str.c_str(),           -1,           pElementText,           iTextLen,           NULL,         NULL   ); string strText; strText = pElementText; delete[]   pElementText; return strText;}
CSOAP::CSOAP()
{
 InitSoap();
}
CSOAP::~CSOAP()
{
 soap_destroy(&m_soap);
 soap_end(&m_soap);
 soap_done(&m_soap);
}
bool CSOAP::InitSoap()
{  
 soap_init(&m_soap);
 soap_set_mode(&m_soap,SOAP_C_UTFSTRING);
 m_soap.mode|=SOAP_C_UTFSTRING;
 header.ns1__MySoapHeader_=new ns1__MySoapHeader;
 header.ns1__MySoapHeader_->PassWord=&headerPass;
 header.ns1__MySoapHeader_->UserName=&headerName;
 m_soap.header=&header;
 return true;
}
bool CSOAP::EnLogin(CString name,CString pass,CString &tip)//管理员登陆
{
 _ns1__UserLogin login;
 _ns1__UserLoginResponse loginResponse;
 string loginPass=pass;
 string loginName=name;
 login.PassWord=&loginPass;
 login.UserName=&loginName;
 m_soap.header=&header;
 if(SOAP_OK==soap_call___ns2__UserLogin(&m_soap,NULL,NULL,&login,&loginResponse))
 {
 Sleep(500);
 tip=DecodeUtf8(loginResponse.UserLoginResult->ResultContent->c_str());
 if(loginResponse.UserLoginResult->ErrorCode==0)
 return true;
 else 
 return false;
 }
 else
 {  
 tip=_T("网络连接失败");
 //tip.Format(_T("%s"),*soap_faultstring(&m_soap));
 return false;
 }
}


相关文章
|
8月前
交叉编译安装tslib
交叉编译安装tslib
98 0
|
数据可视化 C++
msvc编译opencascade和vtk
1.opencascade源码 我下载的时候最新版本是7.7.0
236 0
|
Windows
zlib、libzip、 libzippp 库编译(windows + cmake + vs2013)
"libzipp" 这库是基于 "libzip" 之上封装的,而 "libzip" 又是基于 "zlib"库封装的,所以要编译 "libzipp" 库就要先编译其他两个库。下载准备:"zlib-1.2.
3833 0
|
机器学习/深度学习 C语言 数据安全/隐私保护
windows下安装MinGW、swig 、zlib
windows下安装MinGW、swig 、zlib
580 0
|
C语言
Qt使用Gsoap
Qt使用Gsoap
133 0
gtk/gtk.h 没有那个文件或目录
gtk/gtk.h 没有那个文件或目录
198 0
|
XML JSON 监控
Onvif开发笔记(一):使用gSOAP编译Onvif协议之gSOAP介绍与编译
Onvif开发笔记(一):使用gSOAP编译Onvif协议之gSOAP介绍与编译
Onvif开发笔记(一):使用gSOAP编译Onvif协议之gSOAP介绍与编译
|
Web App开发 XML C++
gsoap开发webservice
gSOAP编译工具提供了一个SOAP/XML 关于C/C++ 语言的实现,从而让C/C++语言开发web服务或客户端程序的工作变得轻松了很多。绝大多数的C++web服务工具包提供一组API函数类库来处理特定的SOAP数据结构,这样就使得用户必须改变程序结构来适应相关的类库。
1332 0