473,748 Members | 2,528 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.....The re 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.Bas ically 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::CHPVROO MS v;
VROOMS::VRoomsP artnerAuth AuthInfo;

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

v.VRoomsPartner Auth11 = 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 HostingLocation s { NOHOSTINGAVAILA BLE = 0,
EXTERNALHOSTING _LOCATION = 1, INTERNALHOSTING _LOCATION = 2,
INTERNALANDEXTE RNALHOSTING = 3, };

struct VRoomsPartnerAu th
{
BSTR AccountName;
BSTR SubAccountName;
BSTR Pwd;
};

template <typename TClient = CSoapSocketClie ntT<> >
class CHPVROOMST :
public TClient,
public CSoapRootHandle r
{
public:

//
// SOAP headers
//

VRoomsPartnerAu th VRoomsPartnerAu th22;
VRoomsPartnerAu th VRoomsPartnerAu th31;
VRoomsPartnerAu th VRoomsPartnerAu th24;
VRoomsPartnerAu th VRoomsPartnerAu th21;
VRoomsPartnerAu th VRoomsPartnerAu th20;
VRoomsPartnerAu th VRoomsPartnerAu th17;
VRoomsPartnerAu th VRoomsPartnerAu th16;
VRoomsPartnerAu th VRoomsPartnerAu th15;
VRoomsPartnerAu th VRoomsPartnerAu th13;
VRoomsPartnerAu th VRoomsPartnerAu th6;
VRoomsPartnerAu th VRoomsPartnerAu th14;
VRoomsPartnerAu th VRoomsPartnerAu th7;
VRoomsPartnerAu th VRoomsPartnerAu th5;
VRoomsPartnerAu th VRoomsPartnerAu th32;
VRoomsPartnerAu th VRoomsPartnerAu th9;
VRoomsPartnerAu th VRoomsPartnerAu th8;
VRoomsPartnerAu th VRoomsPartnerAu th19;
VRoomsPartnerAu th VRoomsPartnerAu th10;
VRoomsPartnerAu th VRoomsPartnerAu th12;
VRoomsPartnerAu th VRoomsPartnerAu th29;
VRoomsPartnerAu th VRoomsPartnerAu th18;
VRoomsPartnerAu th VRoomsPartnerAu th11;
VRoomsPartnerAu th VRoomsPartnerAu th23;
VRoomsPartnerAu th VRoomsPartnerAu th30;
VRoomsPartnerAu th VRoomsPartnerAu th28;

protected:

const _soapmap ** GetFunctionMap( );
const _soapmap ** GetHeaderMap();
void * GetHeaderValue( );
const wchar_t * GetNamespaceUri ();
const char * GetServiceName( );
const char * GetNamespaceUri A();
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
VRoomsPartnerAu th like
VRoomsPartnerAu th11 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\Bi naries\MSSOAP30 .dll" \
exclude("IStrea m", "ISequentialStr eam", "_LARGE_INTEGER ", \
"_ULARGE_INTEGE R", "tagSTATSTG ", "_FILETIME" )
using namespace MSSOAPLib30;

void f0()
{
try()
{
ISoapSerializer Ptr Serializer,s;
ISoapReaderPtr Reader;
ISoapConnectorP tr Connector;
// Connect to the service
Connector.Creat eInstance(__uui dof(HttpConnect or30));
Connector->Property["EndPointUR L"] =
"https://www.websevice.c om/service.asmx";
Connector->Connect();

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

// Create the SoapSerializer
Serializer.Crea teInstance(__uu idof(SoapSerial izer30));

// Connect the serializer to the input stream of the connector
Serializer->Init(_variant_ t((IUnknown*)Co nnector->InputStream) );

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

Serializer->StartHeader("" );
Serializer->StartElement(" VRoomsPartnerAu th","http://webesrvice.com/","","");
Serializer->StartElement(" AccountName","" ,"","");
Serializer->WriteString("a ccname");
Serializer->EndElement() ;

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

Serializer->StartElement(" Pwd","","","") ;
Serializer->WriteString("p assword");
Serializer->EndElement() ;
Serializer->EndElement() ;
Serializer->EndHeader();
Serializer->StartBody("" );
Serializer->StartElement(" websermethod1", "http://webservice.com/",
"", "M");
Serializer->StartElement(" PartnerRefStr", "","","");
Serializer->WriteString("r efstring");
Serializer->EndElement() ;
Serializer->EndElement() ;

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

// Read the response
Reader.CreateIn stance(__uuidof (SoapReader30)) ;

// Connect the reader to the output stream of the connector
Reader->Load(_variant_ t((IUnknown*)Co nnector->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(NU LL);
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 6204

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

Similar topics

17
14791
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 web-service in a an asynchronous mode (with a callback function)? If so, how?
4
6728
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 service: <WebService(Namespace:="http://tempuri.org/")> _ Public Class TextData Inherits System.Web.Services.WebService
1
1361
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 got to install on the clients PC to be able to access these webservices?? Will just the .NET Framework suffice??? Or do i have to install SOAP?? note - the OS of the client can be win98, win2K, win3000, winXP
7
4986
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 Parameter. I can call the first Method without Problems, the Parameter can be deserialized by the WebService. But if I want to call the second Method and give it an Array of Parameters, then the following exception is thrown by the WebService:...
3
12886
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 use SOAP, to connect to it, but how?? Are there any good documentation for that?? all the examples that i've found, is using web-refference.. Thanks
2
1537
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? One possible scenario could be to redirect VIPs to a more powerful webfarm than the one the common user uses. But is it a good solution and, in case it is, can I implement it using some of the standard features in .net (or perhaps .net v2)? ...
3
4285
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 web services using HTTP protocol, which is not acceptible - generating SOAP messages for arbitrary web services is something i wish to avoid. I need a package/tool that generates web service proxies that will do
8
2774
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 server expects to get String_1 first, but somehow my client (C# .net cf) sends String_2 first.. On top of that, If i build solution and run the .exe file, it works fine.
10
10579
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 type="traceextension, simpleModule" priority="1" group="high"/> </soapExtensionTypes> </webservices>
5
8816
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 implement C# webservices is to put them in asp.net (.asmx) files and hosted by IIS. Access to these services is of the form: http://localhost/webservicetest/service.asmx. For various reasons, I don’t want to do that.) I can successfully connect...
0
8995
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8832
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9561
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8252
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6799
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3316
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.