2010-07-27 38 views
15

Tôi đang cố gắng để có được một ví dụ đơn giản làm việc bằng cách sử dụng gSoap, cho VS2008.biên soạn gSoap với C++

tôi đã thực hiện như sau:

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

Và rồi này:

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

trong đó sản xuất nhiều tập tin. Thư mục dự án của tôi trông giống như sau:

// 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 

Khi tôi xây dựng, tôi nhận được rất nhiều lỗi liên kết (không được giải quyết bên ngoài). Tôi không thể tìm thấy bất kỳ thứ gì để liên kết với (ví dụ: không có thư viện nhị phân) - tôi thiếu gì?

Tôi tin rằng điều này có thể có cái gì để làm với những điều sau đây từ các tài liệu:

Để hoàn thành việc xây dựng, biên soạn và liên kết soapC.cpp tạo, soapcalcProxy.cpp, và run- thời gian công cụ gSOAP -gsoap ++ (hoặc sử dụng nguồn stdsoap2.cpp trong trường hợp libgsoap ++. a là chưa được cài đặt) với mã của bạn.

có thư viện gsoap ++ cho win32 không?

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 *)" ([email protected]@[email protected]@[email protected]) 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 *)" ([email protected]@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@Z) 
1>ortC.obj : error LNK2019: unresolved external symbol "int __cdecl soap_putindependent(struct soap *)" ([email protected]@[email protected]@@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 *)" ([email protected]@[email protected]@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]) 
1>ortC.obj : error LNK2019: unresolved external symbol "int __cdecl soap_getindependent(struct soap *)" ([email protected]@[email protected]@@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 *)" ([email protected]@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@Z) 
1>ortC.obj : error LNK2019: unresolved external symbol "int __cdecl soap_fdelete(struct soap_clist *)" ([email protected]@[email protected]@@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 *)" ([email protected]@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]) 
1>ortC.obj : error LNK2019: unresolved external symbol "void __cdecl soap_default_int(struct soap *,int *)" ([email protected]@[email protected]@[email protected]) referenced in function "public: virtual void __thiscall _ns1__initalizePlayerResponse::soap_default(struct soap *)" ([email protected][email protected]@[email protected]@@Z) 
1>ortC.obj : error LNK2019: unresolved external symbol "int __cdecl soap_out_int(struct soap *,char const *,int,int const *,char const *)" ([email protected]@[email protected]@[email protected]) referenced in function "int __cdecl soap_out__ns1__initalizePlayerResponse(struct soap *,char const *,int,class _ns1__initalizePlayerResponse const *,char const *)" ([email protected]@[email protected]@[email protected]@[email protected]) 
1>ortC.obj : error LNK2019: unresolved external symbol "int __cdecl soap_ignore_element(struct soap *)" ([email protected]@[email protected]@@Z) referenced in function "class _ns1__initalizePlayerResponse * __cdecl soap_in__ns1__initalizePlayerResponse(struct soap *,char const *,class _ns1__initalizePlayerResponse *,char const *)" ([email protected]@[email protected]@[email protected]@[email protected]@Z) 
1>ortC.obj : error LNK2019: unresolved external symbol "int * __cdecl soap_in_int(struct soap *,char const *,int *,char const *)" ([email protected]@[email protected]@[email protected]) referenced in function "class _ns1__initalizePlayerResponse * __cdecl soap_in__ns1__initalizePlayerResponse(struct soap *,char const *,class _ns1__initalizePlayerResponse *,char const *)" ([email protected]@[email protected]@[email protected]@[email protected]@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 ========== 

Trả lời

19

Được rồi, đối với những thất vọng với các tài liệu trên trang web gSoap, sử dụng VS2008 để biên dịch một khách hàng nhanh chóng chỉ dụ, đây là các bước (máy chủ khác nhau).

Tạo file header từ WSDL: wsdl2h -o init.h http://bleh.com/myservice.asmx?WSDL

Tạo file xà phòng client:

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

Đảm bảo bạn thêm các tập tin sau đây để giải pháp của bạn cho xây dựng:

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

Đảm bảo rằng, đối với mỗi tệp này, bạn chọn tùy chọn trình biên dịch "Không sử dụng tiêu đề được biên dịch trước". (Thuộc tính tệp -> C++ -> Tiêu đề được biên dịch trước -> Tạo/Sử dụng tiêu đề được biên dịch trước).

Cuối cùng, thêm tệp .nsmap được tạo cho proxy của bạn vào stdafx.h (hoặc trong chính nếu dự án của bạn không sử dụng tiêu đề được biên dịch trước).

Dưới đây là một ví dụ mà làm cho một truy vấn đơn giản:

// 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; 
} 

hy vọng điều này giúp một ai đó!

+1

Chỉ một bình luận: không gian tên nên được thêm vào stdafx.cpp (không phải .h)! – Budda

+0

bạn có nghĩa là bao gồm tệp .nsmap trong stdafx.cpp không? Tôi đã thử nó và nó không hoạt động – Alex