473,385 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Calling Webservices from c++ using dot net Framework/Soap tool kit 3.0-Help reqd....

Hi,
I have a requirement to call webservices from my old C++
application.So first I tried with Vc++.net as follows.....There are 2
approach Dotnet frame work and soaptoolkit 3.0
I am not able to interact with webservice thru c++.I think ther is a
bug in MS implementation for c++ to interact with webservice because I
am able to connect to the same webservice thru C# as well as vb.net.

I tried the following approaches

Approach I:Using Dot net framework + ATL:
==========================================
1)I opened vc++.net and select Vc++ proj-> console app with ATL
support and add the webservice asmx file as webreferences..I tried to
interact with the webservices.Basically it has an authentication
mechanism that you have to send ur username and passwd thru the soap
header.So the code fragment i wrote is as follows..

#include "stdafx.h"

using namespace std;

void f0(){

VROOMS::CHPVROOMS v;
VROOMS::VRoomsPartnerAuth AuthInfo;

AuthInfo.AccountName = SysAllocString(L"username");
AuthInfo.Pwd = SysAllocString(L"passwd");

v.VRoomsPartnerAuth11 = AuthInfo;

int res = -1;
BSTR prs = SysAllocString(L"username");
HRESULT hr = v.webservice method1(prs, &res);
}

int _tmain(int argc, _TCHAR* argv[])
{

OleInitialize(0);
f0();
OleUninitialize();

return 0;
}Basically it is not authenticating and Iam getting E_FAIL. The proxy
class created by Vc++ 7 is as follows (code fragment)
================================================== ============================

#include <atlsoap.h>

namespace HPVROOMS
{

enum HostingOptions { NORECORDING = 0, EXTERNALHOSTING_ONLY = 1,
INTERNALHOSTING_ONLY = 2, DOWNLOAD_ONLY = 3, EXTERNALHOSTING_DOWNLOAD
= 4, INTERNALHOSTING_DOWNLOAD = 5, };

enum HostingLocations { NOHOSTINGAVAILABLE = 0,
EXTERNALHOSTING_LOCATION = 1, INTERNALHOSTING_LOCATION = 2,
INTERNALANDEXTERNALHOSTING = 3, };

struct VRoomsPartnerAuth
{
BSTR AccountName;
BSTR SubAccountName;
BSTR Pwd;
};

template <typename TClient = CSoapSocketClientT<> >
class CHPVROOMST :
public TClient,
public CSoapRootHandler
{
public:

//
// SOAP headers
//

VRoomsPartnerAuth VRoomsPartnerAuth22;
VRoomsPartnerAuth VRoomsPartnerAuth31;
VRoomsPartnerAuth VRoomsPartnerAuth24;
VRoomsPartnerAuth VRoomsPartnerAuth21;
VRoomsPartnerAuth VRoomsPartnerAuth20;
VRoomsPartnerAuth VRoomsPartnerAuth17;
VRoomsPartnerAuth VRoomsPartnerAuth16;
VRoomsPartnerAuth VRoomsPartnerAuth15;
VRoomsPartnerAuth VRoomsPartnerAuth13;
VRoomsPartnerAuth VRoomsPartnerAuth6;
VRoomsPartnerAuth VRoomsPartnerAuth14;
VRoomsPartnerAuth VRoomsPartnerAuth7;
VRoomsPartnerAuth VRoomsPartnerAuth5;
VRoomsPartnerAuth VRoomsPartnerAuth32;
VRoomsPartnerAuth VRoomsPartnerAuth9;
VRoomsPartnerAuth VRoomsPartnerAuth8;
VRoomsPartnerAuth VRoomsPartnerAuth19;
VRoomsPartnerAuth VRoomsPartnerAuth10;
VRoomsPartnerAuth VRoomsPartnerAuth12;
VRoomsPartnerAuth VRoomsPartnerAuth29;
VRoomsPartnerAuth VRoomsPartnerAuth18;
VRoomsPartnerAuth VRoomsPartnerAuth11;
VRoomsPartnerAuth VRoomsPartnerAuth23;
VRoomsPartnerAuth VRoomsPartnerAuth30;
VRoomsPartnerAuth VRoomsPartnerAuth28;

protected:

const _soapmap ** GetFunctionMap();
const _soapmap ** GetHeaderMap();
void * GetHeaderValue();
const wchar_t * GetNamespaceUri();
const char * GetServiceName();
const char * GetNamespaceUriA();
HRESULT CallFunction(
void *pvParam,
const wchar_t *wszLocalName, int cchLocalName,
size_t nItem);
HRESULT GetClientReader(ISAXXMLReader **ppReader);

public:
HRESULT webmethod1(
BSTR RefStr,
int* Result
);

================================================== =============================
The proxy class generated creates too many variables for
VRoomsPartnerAuth like
VRoomsPartnerAuth11 etc.. but this is not happening with C# or VB.net
and only one class is generated and Iam able to interact with web
service successfully in c# or vb.net. Here only this problem comes.
So i moved 2 second approach using Soap tool kit 3.0

Approach -II:Using Soap toolkit 3.0 in VC6/7:
============================================

include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#import "msxml3.dll"
using namespace MSXML2;

#import "C:\Program Files\Common Files\MSSoap\Binaries\MSSOAP30.dll" \
exclude("IStream", "ISequentialStream", "_LARGE_INTEGER", \
"_ULARGE_INTEGER", "tagSTATSTG", "_FILETIME")
using namespace MSSOAPLib30;

void f0()
{
try()
{
ISoapSerializerPtr Serializer,s;
ISoapReaderPtr Reader;
ISoapConnectorPtr Connector;
// Connect to the service
Connector.CreateInstance(__uuidof(HttpConnector30) );
Connector->Property["EndPointURL"] =
"https://www.websevice.com/service.asmx";
Connector->Connect();

// Begin message for Multiply
Connector->Property["SoapAction"] =
"http://www.websevice.com/websermethod1";
Connector->BeginMessage();

// Create the SoapSerializer
Serializer.CreateInstance(__uuidof(SoapSerializer3 0));

// Connect the serializer to the input stream of the connector
Serializer->Init(_variant_t((IUnknown*)Connector->InputStream));

// Build the SOAP Message
Serializer->StartEnvelope("","","");

Serializer->StartHeader("");
Serializer->StartElement("VRoomsPartnerAuth","http://webesrvice.com/","","");
Serializer->StartElement("AccountName","","","");
Serializer->WriteString("accname");
Serializer->EndElement();

Serializer->StartElement("SubAccountName","","","");
Serializer->WriteString("subacc name");
Serializer->EndElement();

Serializer->StartElement("Pwd","","","");
Serializer->WriteString("password");
Serializer->EndElement();
Serializer->EndElement();
Serializer->EndHeader();
Serializer->StartBody("");
Serializer->StartElement("websermethod1","http://webservice.com/",
"", "M");
Serializer->StartElement("PartnerRefStr","","","");
Serializer->WriteString("refstring");
Serializer->EndElement();
Serializer->EndElement();

Serializer->EndBody();
Serializer->EndEnvelope();
// Send the message to the web service
Connector->EndMessage();

// Read the response
Reader.CreateInstance(__uuidof(SoapReader30));

// Connect the reader to the output stream of the connector
Reader->Load(_variant_t((IUnknown*)Connector->OutputStream,""),
"");

// Display the result
printf("Answer for websermethod: %s\n", (const char
*)Reader->RpcResult->text);
}
catch(com error e)
{
printf("The error desc is %s\n", e.description());
}
}

int _tmain(int argc, _TCHAR* argv[])
{
CoInitialize(NULL);
f0();
CoUninitialize();
return 0;
}
================================================== ==============================

Here Iam getting "Connection Timed out" error here. I found out from
MSDN that there is a bug with soap toolkit 2.0
FIX: SOAP SDK: ConnectTimeout Does Not Apply to Dotted IP Address
The url is
http://support.microsoft.com/default...s%3BQ311275#ap

but it is told that it is fixed in MS soap tool kit 3.0.but i am
getting the same kind of error using tool kit 3.0 also.
Also this problem is clearly with problems in MS implementation for
c++ to interact with webservice because I am able to connect to the
same webservice thru C# as well as vb.net.

So any takers pls????
Nov 21 '05 #1
0 6170

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Patrick | last post by:
I am almost certain that I could use HTTP Post/Get to submit XML Web Service call (over SSL as well, if using Version 3 of MSXML2) from an ASP Application? However, would I only be able to call...
4
by: Julian Hershel | last post by:
Hi. I have a very simple web service that I am trying to call from a classic ASP page. The web service project and the ASP page are both on my development machine. That's the code of my web...
1
by: Jinashe | last post by:
what do i need to enable accessing of webservices from a clients PC i'm hosting some webservices from my server in VB.NET. i've got some client windows applications done in VB.NET. what have i...
7
by: Christian Wilhelm | last post by:
Hi! I'm trying to call a Java WebService out of a .net Client. There are two Methods, one Method requires one Parameter of type Parameter, the other Method requires one Parameter of type...
3
by: Henrik | last post by:
Hi all,,, I need to get a refferece to a XML-webservice, and get some data from it.... But I can't add it like an web-refference... What options does I else have?? I've been told that i've to...
2
by: Peter Norregaard | last post by:
Our customers have different names SLA’s / Service Level Agreements but use the same webservice. How do I handle that some users can be allowed to wait when the load is high while others can’t?...
3
by: Ivan Zuzak | last post by:
Hello, My Python application calls web services available on the Internet. The web service being called is defined through application user input. The Python built-in library allows access to...
8
by: Duffcase | last post by:
Hi. I'm having some problems consuming a webservice. The server keeps complaining about the wrong element beeing sent.. I have this method that takes two strings String_1 and String_2 The...
10
by: smarty | last post by:
Hi, I have written a WSE in vis studio 2005 as and produced a dll that I can use in other projects by including the following in the web.config. <webservices> <soapextensiontypes> <add...
5
by: TayBill | last post by:
I have C# based webservice that is hosted in a NT service. Programmatic access to the web service is of the form: soap.tcp://localhost:11141/ProcessorWebService (The more traditional way to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.