I found a lot of this article on the Internet, the real can achieve out of almost no.
Only I downloaded and debugged the successful case 1 years ago. Then gSOAP is a more complex implementation process, the need to learn more theoretical knowledge, need to know more about the official website to download.
It is useful to use other people's articles when debugging, but be sure to see the version number of the Debug tool .
1.1.1.1 Environment
L VS2012
L gSOAP 2.8.14 (please use the specified version)
L WIN7 IIS
1.1.1.2 Download gSOAP package GSOP2.8
The 1.1.1.3 C # program establishes a WCF service and deploys it to IIS.
public interface IService1
{
[OperationContract]
string GetData (int value);
[OperationContract]
Compositetype getdatausingdatacontract (Compositetype composite);
TODO: Add your service actions here
[OperationContract]
Double Add (double A, double b);
[OperationContract]
Double sub (double A, double b);
[OperationContract]
Double Mul (double A, double b);
[OperationContract]
Double Div (double A, double b);
}
public class Service1:iservice1
{
TODO: Add your service actions here
Public double Add (double A, double b)
{
return a + B;
}
Public double sub (double A, double b)
{
return a-B;
}
Public double Mul (double A, double b)
{
return a * b;
}
Public Double div (double A, double b)
{
return a/b;
}
}
1.1.1.4 found \gsoap\gsoap-2.8\gsoap\bin\win32.
1.1.1.5 use CMD to enter the directory below, as
Chart 5.9.6?1
1.1.1.6 Input command generates C + + XXXX.h file
The command is as follows:
Wsdl2h-s-T Typemap.dat-o service2.h
http://localhost:52852/WCFService1/Service.svc?wsdl
Typemap.dat file to be placed in the Gsoap\gsoap-2.8\gsoap\bin\win32 directory, execution of the command will produce Service2.h file.
Chart 5.9.6?2
1.1.1.7 input to generate soapstub.h,soapc.cpp and other files.
After copying the Service2 file to the Gsoap\import folder, execute
Command: soapcpp2-c-i D:\soft\GSOAP\gsoap-2.8\gsoap\import service1.h-l-i–x
Soapcpp2-c-I F:\VC use gSOAP invoke C#WCF service \gsoap-2.8\gsoap\import\ service2.h-l-i-x
Chart 5.9.6?3
Execution results
Chart 5.9.6?4
1.1.1.8 copy the resulting file into the VC project and add it to the VC project
Because STL is not used, it is necessary to include stdsoap2.h and Stdsoap2.cpp, which are two files that can be found in gSOAP.
1.1.1.9 set all. cpp files for new addition do not use precompiled headers
Chart 5.9.6?5
1.1.1.10 Compile connection error handling:
stdsoap2/h Remove: extern soap_nmac struct Namespace namespaces[];
Ten: Add execution Code:
Const char* server= "HTTP://XXXXX:81/SERVICE1.SVC"; "Http://localhost/srv/srv.asmx";
Basichttpbinding_uscoreiservice1proxy SS (server,soap_c_utfstring);
Double aa=10;
double bb = 20;
_tempuri__add Tempuri__add;
tempuri__add.a=&aa;
TEMPURI__ADD.B =&bb;
_tempuri__addresponse Tempuri__addresponse;
if (Ss.add (&tempuri__add,&tempuri__addresponse) ==SOAP_OK)
{
Double Cc=*tempuri__addresponse.addresult;
Ss.destroy ();
return 0;
}
if (ss.error)
{
Ss.soap_stream_fault (Std::cerr);
Ss.destroy ();
return 0;
}
Chart 5.9.6?6
1.1.1.11 Running error Handling
Namespaces[] Substitution in the Soapbasichttpbinding_uscoreiservice1proxy.cpp,basichttpbinding_uscoreiservice1.nsmap file
1.1.1.12 successfully implemented C + + calling C # WCF Service
Chart 5.9.6?7
N Define with_nonamespaces macros in the project
n Try "#include" Namp.nsmap ""
VC calls C#WCF service using gSOAP (2.8.14)