• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 215
  • Last Modified:

VC++ && Webservices


hi All experts, I have a question for you
Can i use Webservices in VC6++ application?
If so, how do i do that?

A good answer is a project example and some guide line about it, i think.
All replies are appriciate
thanks
0
nghiaap
Asked:
nghiaap
3 Solutions
 
AxterCommented:
You can use the MFC classes CInternetSession, CHttpConnection, CHttpFile

Code will be something like this

          CInternetSession oSession;
          TCHAR szTemp [10000];
          memset(szTemp, 0 , 10000);
         
          //connect to the WebService with the given address
          m_csIPAddress.TrimLeft("http://");
          m_csIPAddress.TrimLeft("www.");


          int nSlashIndex = m_csIPAddress.Find('/',0);
          if( nSlashIndex == -1)
               m_csWebServer  = m_csIPAddress;
          else
               m_csWebServer  = m_csIPAddress.Left( nSlashIndex );

          CHttpConnection* pCon = oSession.GetHttpConnection( m_csWebServer );

          CHttpFile* pFile = 0;

          nSlashIndex = m_csIPAddress.Find('/',0);

          if(nSlashIndex != -1)
               m_csIPAddress = m_csIPAddress.Right(m_csIPAddress.GetLength()-nSlashIndex);

          CString csRequest = m_csIPAddress + "/WebServiceFolder/WebServiceCalling File.ext?";  <--- PLACE YOUR WEBSERVICE NAME HERE
          pFile = pCon->OpenRequest(CHttpConnection::HTTP_VERB_POST,csRequest );

          if( pFile == NULL )
               throw "OpenRequest() failed";

          if( pFile->SendRequestEx(nRequestLength) )
          {
               pFile->WriteString((LPCSTR)csRequestXML);
               pFile->EndRequest();

          }

          if(pFile->Read(szTemp, 10000) < 1 )
               throw "Read(szTemp, 10000) failed";

0
 
jkrCommented:
MS and therefore MFC maily use SOAP for web services. Check out http://msdn.microsoft.com/msdnmag/issues/02/04/SOAP/default.aspx ("SOAP: Using ATL Server to Build an Asynchronous SOAP Client in Unmanaged C++ -- MSDN Magazine, April 2002"). Also, there a some samples available at http://msdn.microsoft.com/library/en-us/vcsample/html/vcoricategoricallistofatlserversamples.asp?frame=true#catsatlserversamples_soap ("Samples that demonstrate XML Web services and clients accessible with SOAP and created using the support provided by ATL Server")
0
 
jkrCommented:
BTW, http://www.codeproject.com/internet/webresourceprovider.asp ("WebResourceProvider - A framework to allow public web services to be used as objects in your application") could be interesting also.
0
 
NawalKishore1976Commented:
Using the CinternetFile , you can download the dynamic XML pages from internet and create the simple consumner application.
0
 
nghiaapAuthor Commented:
wwwwooaaaoooo
Is it that there are so many for me ;) (just joking), ok i'll give them a try, thks aaaallllll
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now