Avatar of m_kristofer
m_kristoferFlag for Philippines asked on

accessing/using web service from C++ windows application

Hi Experts,

How can I access web services on the web using MFC/C++ windows application?

Can u teach me the step by step process how to communicate with the web service? I tried from the internet but I could not make it work. I create a web service from C# and compiled and run it. but I could not access it in my mfc windows application. the example I get only have .asmx file not .wsdl file. how can I make a .wsdl file from c#? I hope you can help me on this. I've been googling the whole day but I could not make it work.

Thanks.

Kristofer
System ProgrammingWeb DevelopmentC++

Avatar of undefined
Last Comment
mahesh1402

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
evilrix

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
alb66

From menu Project select "Add web reference" and let the wizard create a service wrapper for you.
ASKER
m_kristofer

Thanks for your replies.

I already made the .asmx file but I cannot access it with my windows application using soap client. The example I have is locating the .wsdl file(http://www.myserver.com/SoapSamples/MyObj.wsdl) not the .asmx file.

the snippet below shows that the defined SRVC refers to a .wsdl file. I tried changing the SRVC to .asmx but it doesn't work. error occurs when line "m_pClient->mssoapinit(SRVC, "", "", "");" is execute.

Maybe if you guys have a better sample code in order for me to access the asmx file would get the points. or make a web service with the extension of .wsdl using c# or C++.

Thanks guys.


//TODO change to your web server location
#define SRVC "http://www.myserver.com/SoapSamples/MyObj.wsdl"
 
BOOL CDemo2Dlg::Connect()
{
	if(!m_bConnected)
	{
		m_pClient = new ISOAPClient;
		if(m_pClient->CreateDispatch("MSSOAP.SoapClient"))
		{
			m_pClient->mssoapinit(SRVC, "", "", "");
			m_bConnected = TRUE;
		}
		else
			return FALSE;
	}
	return TRUE;
}

Open in new window

mahesh1402

>>error occurs when line "m_pClient->mssoapinit(SRVC, "", "", "");" is execute.

Trace HRESULT value for above statement....look if you are getting some error (e.g. -2147024809) which stands for 'The parameter is incorrect.'

e.g.

HRESULT hr;
hr = m_pClient->mssoapinit(SRVC, "", "", "");

Samples on codeproject may be help :
http://www.codeproject.com/KB/XML/VSOAPClient.aspx

-Mahesh
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes