|
Neil,
I am new to the MS world! Do you have a full example??
Cheers,
ted
|
|
|
|
|
I'm creating a client for a web service with VC6 on a Win2000 System.
The SOAP toolkit 3.0 is installed.
The Path to the DLL is ok C:\WINNT\system32\Mssoap30.dll
But I get allways this error:
soapclientbase.h(22) : error C2772: #import referenced a type from a missing type library; '__missing_type__' used as a placeholder
soapclientbase.h(22) : fatal error C1084: Cannot read type library file: 'C:\WINNT\system32\Mssoap30.dll': Fehler beim Laden der Typbibliothek/DLL.
Could anyone help me to solve this problem?
Have I maybe also to use the files mssoap30.lib and mssoap30.h of the toolkit?
Werner
|
|
|
|
|
hi,
I am trying to call webservice from a visual C++. whenever build the code i got the error
#pragma once
/****************************************************************************************************
Soap client helper class for C++
Usage:
1. Inherit a class from this base class
2. Call Init in constructor, like this:
Init("http://localhost/AuthService/AuthService.asmx?wsdl", "AuthService", "");
3. Wrap the webservice by writing proxy function for each web method
4. Call Invoke to execute the function, processing the input params and return value
be careful, the order of parameters should be reversed in the parameter array while callin Invoke
5. Then use this class to call webservice, like this:
AuthServiceClient service;
bool ret = service.IsAuthorized(strCode);
*******************************************************************************************************/
#include "SDKDef.h"
//import soapsdk
//modify the path if needed
#import "E:\Program Files\Common Files\MSSoap\Binaries\mssoap30.dll" \
exclude("IStream", "IErrorInfo", "ISequentialStream", "_LARGE_INTEGER", \
"_ULARGE_INTEGER", "tagSTATSTG", "_FILETIME")
using namespace MSSOAPLib30;
// Base class for calling a webservice using soap
class SoapClientBase
{
protected:
ISoapClient *m_pSoapClient;
char* m_pError;
HRESULT m_hr;
public:
SoapClientBase(void)
{
m_pSoapClient = NULL;
m_pError = NULL;
m_hr = 0;
}
virtual ~SoapClientBase(void)
{
Reset();
}
///////////////////////////////////////////////////////////////////
// Check error message issued by last call(if any)
char* GetLastError()
{
return m_pError;
}
////////////////////////////////////////////////////////////////
// Init SoapClient object
bool Init(char* szWSDLFile, char* szService, char* szPort)
{
Reset();
//create soapclient object
m_hr = ::CoCreateInstance(__uuidof(SoapClient30), NULL, CLSCTX_INPROC_SERVER, __uuidof(ISoapClient), (LPVOID *)&m_pSoapClient);
if (m_pSoapClient==NULL)
{
IssueError("Create soap client object fail");
return false;
}
//init soap client
_variant_t varWSDL = szWSDLFile;
_variant_t varWSML = "";
_bstr_t bstrService = szService;
_bstr_t bstrPort = szPort;
_bstr_t bstrNS = "";
m_hr = m_pSoapClient->MSSoapInit2(varWSDL, varWSML, bstrService, bstrPort, bstrNS);
if (FAILED(m_hr))
{
IssueError("Error calling MSSoapInit2");
return false;
}
return true;
}
protected:
///////////////////////////////////////////////////////////////////
// Record an error message issued by this class or inherited
void IssueError(char* szError)
{
if (m_pError)
delete [] m_pError;
m_pError = new char[strlen(szError)+1];
strcpy(m_pError, szError);
}
////////////////////////////////////////////////////////////////////
// Release interface, free memory, clean everything
void Reset()
{
if (m_pSoapClient)
{
m_pSoapClient->Release();
m_pSoapClient = NULL;
}
if (m_pError)
{
delete [] m_pError;
m_pError = NULL;
}
m_hr = S_OK;
}
protected:
/////////////////////////////////////////////////////////////////////////////////////////
// the following code is copied from ATL code(CComDispatchDriver), and modified
HRESULT GetIDOfName(LPCOLESTR lpsz, DISPID* pdispid)
{
return m_pSoapClient->GetIDsOfNames(IID_NULL, (LPOLESTR*)&lpsz, 1, LOCALE_USER_DEFAULT, pdispid);
}
// Invoke a method by DISPID with N parameters
HRESULT Invoke(DISPID dispid, VARIANT* pvarParams, int nParams, VARIANT* pvarRet = NULL)
{
DISPPARAMS dispparams = { pvarParams, NULL, nParams, 0};
return m_pSoapClient->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dispparams, pvarRet, NULL, NULL);
}
// Invoke a method by name with Nparameters
HRESULT Invoke(LPCOLESTR lpszName, VARIANT* pvarParams, int nParams, VARIANT* pvarRet = NULL)
{
HRESULT hr;
DISPID dispid;
hr = GetIDOfName(lpszName, &dispid);
if (SUCCEEDED(hr))
hr = Invoke(dispid, pvarParams, nParams, pvarRet);
return hr;
}
};
error is :
error C2501: 'SoapClientBase::m_pSoapClient' : missing storage-class or type specifiers
error C2501: 'SoapClientBase::ISoapClient' : missing storage-class or type specifiers
error C2143: syntax error : missing ';' before '*'
error C2871: 'MSSOAPLib30' : a namespace with this name does not exist
please help me.
Brij Bihari Gupta(B.E.I.T.)
|
|
|
|
|
I hope this helps(even if it is late):
This problem ("missing storage-class or type specifiers") is generally caused by a misplaced #include "stdafx.h" .This line has to be the first "#include" in an .CPP file and must not be anywhere else(example: the .h file for that .cpp).The problem is generated by the "precompiled header" option of VC6.0(which is set by default).
|
|
|
|
|
Hi,
Iam trying to call webservice from a vc 6 win32 dll. Everything goes fine uptill the creation of inherited class, here is my code for inherited class
#pragma once
#include "SoapClientBase.h"
class ConsumeWEbService : public SoapClientBase
{
public:
ConsumeWEbService(void) : SoapClientBase()
{
Init("http://localhost/FXPWS/Service.asmx?wsdl", "ConsumeService", "");
}
LPCTSTR Identify(LPCTSTR input, LPCTSTR output, LPCTSTR schema)
{
_variant_t varParams[3] = { input, output, schema };
_variant_t varResult;
m_hr = Invoke(L"Identify", varParams, 3, &varResult);
return VARIANT_TRUE == varResult.boolVal;
}
};
Problem is when i try to create object of this class and I include the line #include "ConsumeWEbService.h" in any file of my project i got 102 errors, i know it has to do something with header file but can anybody guide me in this regard how i can call the service.
errors thrown are something like that:
error C2871: 'MSSOAPLib30' : does not exist or is not a namespace
error C2146: syntax error : missing ';' before identifier 'Dom'
error C2501: 'IXMLDOMDocumentPtr' : missing storage-class or type specifiers
error C2501: 'Dom' : missing storage-class or type specifiers
.
.
.
Bundle of thanks in advance, can anybody help me out?
|
|
|
|
|
You must have soap sdk installed first.
|
|
|
|
|
I have SOAP sdk 3.0 installed. I have included soap include and lib in my project directories. But errors are still coming while compiling. Is it possible that i can call VS.NET 2005 web service from VC6 win32 dll?
debug\mssoap30.tlh(201) : error C2146: syntax error : missing ';' before identifier 'Dom'
debug\mssoap30.tlh(201) : error C2501: 'IXMLDOMDocumentPtr' : missing storage-class or type specifiers
debug\mssoap30.tlh(201) : error C2501: 'Dom' : missing storage-class or type specifiers
debug\mssoap30.tlh(203) : error C2146: syntax error : missing ';' before identifier 'Envelope'
.
.
.
102 errors.
|
|
|
|
|
hi!
to remove this error add these line in ur stdAfx.h file before #endif
#import <msxml.dll> named_guids
using namespace MSXML;
Raj
|
|
|
|
|
add these lines before importing soap sdk
#import "msxml4.dll"
using namespace MSXML2;
|
|
|
|
|
Neither one of these worked for me.
|
|
|
|
|
Simply add...
#import <msxml4.dll>
... to stdafx.h to overcome this one. That's what gives you the smart pointers like IXMLDOMDocumentPtr. You'll need to rebuild your solution after this, if Visual Studio doesn't do it for you.
-- modified at 1:36 Wednesday 5th September, 2007
Rob
|
|
|
|
|
hello
you like make friends in China and all over the world.,.so lets start
any one have client server key logger code idea..plz reply me afri.591011@yahoo.com
|
|
|
|
|
hi
any one have client server key logger code idea..plz reply me afri.591011@yahoo.com
|
|
|
|
|
Hi,
I'm try to connect to a web service located on the Sun Application Server 9.0.
The service initialization goes well, but when I try to invoke the metod, it returns an error.
Does anybody know if the SOAP Toolkit 3 is incompatible with the Sun Application Server 9?
Thx
Luca
|
|
|
|
|
I am using Soap Client and my code is as the following.my question is How can I get Error message from varResult
Thanks.
#pragma once
#include "SoapClientBase.h"
class AuthServiceClient : public SoapClientBase
{
public:
AuthServiceClient(void) : SoapClientBase()
{
Init("http://localhost/AuthService/AuthService.asmx?wsdl", "AuthService", "");
}
bool IsAuthorized(LPCTSTR username, LPCTSTR password)
{
_variant_t varParams[2] = { password, username };
_variant_t varResult;
m_hr = Invoke(L"IsAuthorized", varParams, 2, &varResult);
return VARIANT_TRUE == varResult.boolVal;
}
};
|
|
|
|
|
try to debug your program and see what's in the varResult.
|
|
|
|
|
How can I get vecotr of string from varResult when the code is:
_variant_t varParams[1] = {""};
_variant_t varResult;
HRESULT hr = SoapClient.Invoke(L"GetCategories", varParams, 0, &varResult);
Thanks in advance
arsm
|
|
|
|
|
I paste the code into a project, when the application call m_pSoapClient->MSSoapInit2(....) function, which call "raw_MSSoapInit2", alway get the "invalid parameter" error message, and the application crash.
How to solve it?
thanks!
|
|
|
|
|
I have the same problem. When I call the Invoke function with my web service function name, it returns with error and my app crashes.
Do you have any idea?
Best regards,
A. Riazi
|
|
|
|
|
Hello there
Reading on MSDN... It says the following
SOAP Toolkit 3.0
Brief Description
The Microsoft SOAP Toolkit is deprecated by the .NET Framework. SOAP Toolkit support will be retired in April 2005.
SO - how do we go about using / consuming a Web service, in an MFC / C++ application?
Hope someone can help me
Thanks
Alex
|
|
|
|
|
It is now July 2006. Did you ever find a way to use C++ with web service technology?
mike
|
|
|
|
|
Hi Neil,
the code examples are really great. My first app using this Webservice works really good.
But my target application that also has to use a webservice invoke has some problems:
This application has to run "out of the box", that means, that no installation is done before the first launch. It runs directly from a USB-Device or from CD. It seems that the SOAP-Call is the problem, so I copied the SOAP-dll into the application directory and copied it to the usb-stick, but it crashes when running the webservice-call.
Any Idea how to solve this problem? Using C# or .NET doesn't work, because the .NET framework is required and nearly every customer has "only" W2000 or below and NO Framework installed. So my app has to be a single exe or an exe with dlls and no additional installation.
Everything works except the WS-call.
Thanks for helping!
Greets.
|
|
|
|
|
Hi
I am bginer and i need to make clint for webservice <http: www.handigeproducten.nl="" webservice="">
pliz help how to begin or some manual
Thanks.
|
|
|
|
|
Very nice article...
Cheers!
|
|
|
|
|
服务器端的Webservice.asmx如下:
///
/// 创建新用户
[SoapHeader("Credentials")]
[WebMethod(Description = "创建新用户")]
public DataSet CreateNewUser(String userName,
String password,
String nickName,
int sex,
String email,
String face,
String name,
String oicq,
String msn,
String leader)
{
// SecurityHelper.VerifyCredentials(this);
UserData retval = null;
if((new webteach.BusinessFacade.UserSystem()).
CreateUser(userName, password, nickName,
sex, email, face, name, oicq, msn, leader, out retval))
{
return retval;
}
else
{
//if(retval.Tables[0].Rows[0].RowError != String.Empty)
throw new SoapException(string.Empty,SoapException.ClientFaultCode,retval.Tables[0].Rows[0].RowError);
}
}
return (new webteach.BusinessFacade.UserSystem()).GetReplierListOnline(groupID, postID);
}
///
/// 根据用户名,用户密码得到用户基本信息
///
/// <param name="userName" />
/// <param name="password" />
/// <returns>
[SoapHeader("Credentials")]
[WebMethod(Description = "根据用户名,用户密码得到用户基本信息")]
public DataSet GetUserByUserName(String userName, String password)
{
SecurityHelper.VerifyCredentials(this);
return (new webteach.BusinessFacade.UserSystem()).GetUserByUserName(userName, password);
}
}
现在要用VC++6.0在客户端向服务器端Webservice.asmx注册一个新用户以及通过发送用户的username和password取得服务器发来的用户信息(一个DataSet),该如何办?
Zjroland from http://www.outsourcexp.com
|
|
|
|
|