簡體   English   中英

使用c ++進行gSoap編譯

[英]gSoap compilation with c++

我試圖用一個簡單的例子來使用gSoap,用於VS2008。

我做了以下事情:

wsdl2h -o Init.h http://myservices/InitalisationService.asmx?WSDL

然后這個:

soapcpp2 -I "C:\3pSDK\gsoap-2.7\gsoap\import" -i -C -limport Init.h

它產生許多文件。 我的項目文件夾如下所示:

// generated files
Init.h
InitalisationServiceSoap.initalizePlayer.req.xml
InitalisationServiceSoap.initalizePlayer.res.xml
InitalisationServiceSoap.nsmap
InitalisationServiceSoap12.initalizePlayer.req.xml
InitalisationServiceSoap12.initalizePlayer.res.xml
InitalisationServiceSoap12.nsmap
ortC.cpp
ortH.h
ortInitalisationServiceSoap12Proxy.cpp
ortInitalisationServiceSoap12Proxy.h
ortInitalisationServiceSoapProxy.cpp
ortInitalisationServiceSoapProxy.h
ortMatlab.c
ortMatlab.h
ortStub.h

// Project Files
ReadMe.txt
stdafx.cpp
stdafx.h
WebServicesClient.cpp
WebServicesClient.vcproj
targetver.h

// files added to the project from gSoap folder
stdsoap2.cpp
stdsoap2.h
typemap.dat

當我構建時,我得到了很多鏈接器錯誤(未解析的外部)。 我找不到任何可以鏈接的東西(例如沒有二進制庫) - 我錯過了什么?

我認為這可能與文檔中的以下內容有關:

要完成構建,請使用您的代碼編譯和鏈接生成的soapC.cpp,soapcalcProxy.cpp和運行時gSOAP引擎-lgsoap ++(或使用源stdsoap2.cpp,以防libgsoap ++ .a未安裝)。

win32有一個gsoap ++庫嗎?

 1>Compiling...
 1>WebServicesClient.cpp
 1>ortC.cpp
 1>Generating Code...
 1>Linking...
 1>stdsoap2.obj : error LNK2019: unresolved external symbol _soap_faultcode referenced in function _http_response
 1>stdsoap2.obj : error LNK2001: unresolved external symbol _namespaces
 1>stdsoap2.obj : error LNK2019: unresolved external symbol _soap_getheader referenced in function _soap_recv_header
 1>stdsoap2.obj : error LNK2019: unresolved external symbol _soap_faultsubcode referenced in function _soap_set_fault
 1>stdsoap2.obj : error LNK2019: unresolved external symbol _soap_faultstring referenced in function _soap_set_fault
 1>stdsoap2.obj : error LNK2019: unresolved external symbol _soap_putfault referenced in function _soap_send_fault
 1>stdsoap2.obj : error LNK2019: unresolved external symbol _soap_putheader referenced in function _soap_send_fault
 1>stdsoap2.obj : error LNK2019: unresolved external symbol _soap_serializefault referenced in function _soap_send_fault
 1>stdsoap2.obj : error LNK2019: unresolved external symbol _soap_serializeheader referenced in function _soap_send_fault
 1>stdsoap2.obj : error LNK2019: unresolved external symbol _soap_getfault referenced in function _soap_recv_fault
 1>stdsoap2.obj : error LNK2019: unresolved external symbol _soap_faultdetail referenced in function _soap_set_error
 1>ortC.obj : error LNK2019: unresolved external symbol "void * __cdecl soap_class_id_enter(struct soap *,char const *,void *,int,unsigned int,char const *,char const *)" (?soap_class_id_enter@@YAPAXPAUsoap@@PBDPAXHI11@Z) referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * __cdecl soap_in_std__string(struct soap *,char const *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *,char const *)" (?soap_in_std__string@@YAPAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PAUsoap@@PBDPAV12@1@Z)
 1>ortC.obj : error LNK2019: unresolved external symbol "int __cdecl soap_putindependent(struct soap *)" (?soap_putindependent@@YAHPAUsoap@@@Z) referenced in function "int __cdecl soap_put_std__string(struct soap *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const *,char const *,char const *)" (?soap_put_std__string@@YAHPAUsoap@@PBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PBD2@Z)
 1>ortC.obj : error LNK2019: unresolved external symbol "int __cdecl soap_getindependent(struct soap *)" (?soap_getindependent@@YAHPAUsoap@@@Z) referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * __cdecl soap_get_std__string(struct soap *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *,char const *,char const *)" (?soap_get_std__string@@YAPAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PAUsoap@@PAV12@PBD2@Z)
 1>ortC.obj : error LNK2019: unresolved external symbol "int __cdecl soap_fdelete(struct soap_clist *)" (?soap_fdelete@@YAHPAUsoap_clist@@@Z) referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * __cdecl soap_instantiate_std__string(struct soap *,int,char const *,char const *,unsigned int *)" (?soap_instantiate_std__string@@YAPAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PAUsoap@@HPBD1PAI@Z)
 1>ortC.obj : error LNK2019: unresolved external symbol "void __cdecl soap_default_int(struct soap *,int *)" (?soap_default_int@@YAXPAUsoap@@PAH@Z) referenced in function "public: virtual void __thiscall _ns1__initalizePlayerResponse::soap_default(struct soap *)" (?soap_default@_ns1__initalizePlayerResponse@@UAEXPAUsoap@@@Z)
 1>ortC.obj : error LNK2019: unresolved external symbol "int __cdecl soap_out_int(struct soap *,char const *,int,int const *,char const *)" (?soap_out_int@@YAHPAUsoap@@PBDHPBH1@Z) referenced in function "int __cdecl soap_out__ns1__initalizePlayerResponse(struct soap *,char const *,int,class _ns1__initalizePlayerResponse const *,char const *)" (?soap_out__ns1__initalizePlayerResponse@@YAHPAUsoap@@PBDHPBV_ns1__initalizePlayerResponse@@1@Z)
 1>ortC.obj : error LNK2019: unresolved external symbol "int __cdecl soap_ignore_element(struct soap *)" (?soap_ignore_element@@YAHPAUsoap@@@Z) referenced in function "class _ns1__initalizePlayerResponse * __cdecl soap_in__ns1__initalizePlayerResponse(struct soap *,char const *,class _ns1__initalizePlayerResponse *,char const *)" (?soap_in__ns1__initalizePlayerResponse@@YAPAV_ns1__initalizePlayerResponse@@PAUsoap@@PBDPAV1@1@Z)
 1>ortC.obj : error LNK2019: unresolved external symbol "int * __cdecl soap_in_int(struct soap *,char const *,int *,char const *)" (?soap_in_int@@YAPAHPAUsoap@@PBDPAH1@Z) referenced in function "class _ns1__initalizePlayerResponse * __cdecl soap_in__ns1__initalizePlayerResponse(struct soap *,char const *,class _ns1__initalizePlayerResponse *,char const *)" (?soap_in__ns1__initalizePlayerResponse@@YAPAV_ns1__initalizePlayerResponse@@PAUsoap@@PBDPAV1@1@Z)
 1>G:\Prototypes\WebServicesClient\Debug\WebServicesClient.exe : fatal error LNK1120: 19 unresolved externals
 1>Build log was saved at "file://g:\Prototypes\WebServicesClient\WebServicesClient\Debug\BuildLog.htm"
 1>WebServicesClient - 20 error(s), 0 warning(s)
 ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

好的,對於那些對gSoap網站上的文檔感到沮喪的人,使用VS2008編譯一個快速客戶端的例子,這里是步驟(服務器不同)。

從WSDL生成頭文件:wsdl2h -o Init.h http://bleh.com/myservice.asmx?WSDL

生成soap客戶端文件:

soapcpp2 -C -IC:\3pSDK\gsoap-2.7\gsoap\import Init.h

確保將以下文件添加到解決方案中以進行構建:

soapC.cpp, soapClient.cpp, and stdsoap2.cpp

確保為每個文件選擇編譯器選項“Not using Pre-Compiled headers”。 (文件屬性 - > C ++ - >預編譯標題 - >創建/使用預編譯標題)。

最后,將為代理生成的.nsmap文件添加到stdafx.h(如果您的項目未使用預編譯的頭文件,則在主文件中)。

這是一個簡單查詢的示例:

// WebServicesClient.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "init/soapInitServiceSoapProxy.h"

#include <iostream>
using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{
std::string user = "AAAA";
std::string pass = "BBBB";

InitServiceSoap             service;    

_ns1__initPlayer            query;
_ns1__initPlayerResponse    ans;

query.psParam1 = &user;
query.psParam2 = &pass; 

if( service.__ns2__initPlayer(&query, &ans) == SOAP_OK )
{
    cout << "success!" << endl;     
}

cin.get();

return 0;
}

希望這有助於某人!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM