2010-07-27 3 views
15

저는 VS2008 용 gSoap을 사용하여 간단한 예제를 작성하려고합니다. 다음g C++을 사용하여 컴파일하지 마십시오

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 ++ (또는 libgsoap ++. a가 stdsoap2.cpp 인 경우 이 설치되어 있지 않음)를 사용하십시오.

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 *)" ([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 ========== 

답변

19

좋아, 빠른 클라이언트에게 단지 예를 컴파일 VS2008를 사용하여 gSoap 사이트의 문서와 좌절 사람들을 위해, 여기 단계입니다 (서버는 다르다).

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

당신이 빌드 솔루션에 다음 파일을 추가 확인 :

를 비누 클라이언트 파일을 생성

Init.h http://bleh.com/myservice.asmx?WSDL -o wsdl2h :

하면 WSDL에서 헤더 파일을 생성

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

이러한 파일 각각에 대해 컴파일러 옵션 "미리 컴파일 된 헤더 사용 안함"을 선택해야합니다. (등록 정보 -> 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; 
} 

희망 :

여기에 간단한 쿼리를 만드는 예제입니다!

+1

한 가지 주석 : namespace가 stdafx.cpp에 추가되어야합니다 (.h가 아님)! – Budda

+0

stdafx.cpp에 .nsmap 파일을 포함 하시겠습니까? 나는 그것을 시도하고 그것이 작동하지 않습니다. – Alex

관련 문제