473,779 Members | 1,905 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to call .net WebService from MFC dll written using .net 2003 I

Hi,

I have a vb.net webservice which takes XMLDocument as a parameter and
returns bool. Signature of the method is some thing like this
AddXmlEmpDetail s(xmlEmp as XMLDocument) as Boolean. I am able to call this
method from vb.net desktop client and add a record to the database(this I
used to test if there is any problem in the webservice).

My main requirement is to create a C++(native dll) wrapper what is
recognized by a non microsoft application.

For my testing purpose I am doing the following.

I created a MFC dll (wrapper) using .net 2003 IDE. I created a win32
client using .net 2003 IDE.

I am able to use other webmethods in my wrapper like GetXmlEmpdetail s
which returns an XMLDocument.

I am facing a problem when I am calling AddXmlEmpDetail s(webmethod) in
my wrapper. It say error '500' basically resource not found. I did a debug
and found out that the xml content that I am sending to the webMethod in BSTR
formate is getting changed. For example xml content that i am passing is
like this
[

<Employee><Empl oyeeDetails><Em pID>E116</EmpID><EmpName> Ram</EmpName><EmpAge >35</EmpAge><EmpAddr ess>Mumbai</EmpAddress></EmployeeDetails ></Employee>

]

internally when the soap body is getting built, the content gets changed to
[
<Employee><Empl oyeeDetails><Em pID>E116</EmpID><EmpName> Ram</EmpName><EmpAge >35</EmpAge><EmpAddr ess>Mumbai</EmpAddress></EmployeeDetails ></Employee>

]

because of which I show an error saying invalid node etc.,

Following is what I have code

I have added an com reference for MSXML2.dll

############### ############### ########
[CODE 1
bool CEmpInfoWrapper App::AddEmpDeta ilsWrapper(char chrEmpID[11],char
chrEmpName[26],int intEmpAge,char chrEmpAddress[51])
{
CEmpInfo *webEmpInfoClas s;
HRESULT hr;

webEmpInfoClass =new CEmpInfo();
hr=::CoInitiali ze(NULL);
bool bFunctionStatus ;
bFunctionStatus =false;

CComPtr <IXMLDOMDocumen t> EmpXmlDoc;
hr = EmpXmlDoc.CoCre ateInstance(__u uidof(DOMDocume nt));

bFunctionStatus = true;
//GenerateEmpXml is a user defined function which is also
pasted below
bFunctionStatus =
GenerateEmpXml( chrEmpID,chrEmp Name,intEmpAge, chrEmpAddress,E mpXmlDoc);

if (bFunctionStatu s == false)
{
delete(webEmpIn foClass);
CoUninitialize( );
return bFunctionStatus ;
}

hr=EmpXmlDoc->save(CComVaria nt("C:\\temp\\b eforeadd.xml")) ;

BSTR bstrEmpName;
_bstr_t btEmpName;

EmpXmlDoc->get_xml(&bstrE mpName);

bFunctionStatus =false;

hr=webEmpInfoCl ass->AddXmlEmpDetai ls(bstrEmpName, &bFunctionStatu s);
int errorcode=HRESU LT_CODE(hr);
if (SUCCEEDED(hr))
{
delete(webEmpIn foClass);
CoUninitialize( );
return bFunctionStatus ;
}
else
{
delete(webEmpIn foClass);
CoUninitialize( );
return bFunctionStatus ;
}

}

END OF CODE1]############### ############### ##

############### ############### ############
[Code 2

bool CEmpInfoWrapper App::GenerateEm pXml(char chrEmpID[11],char
chrEmpName[26],int intEmpAge,char chrEmpAddress[51],CComPtr <IXMLDOMDocumen t>
&Root)
{
HRESULT hr1;
hr1=::CoInitial ize(NULL);

//CComPtr <IXMLDOMDocumen t> Root;
CComPtr<IXMLDOM Node> node;
CComPtr<IXMLDOM Node> OddNodeAddress;
CComPtr<IXMLDOM Node> EvenNodeAddress ;
CComPtr <IXMLDOMElement > docElement;
//new
CComPtr <IXMLDOMProcess ingInstruction> xmlPrsInst;
_bstr_t btTarget,btData ;
btTarget = "xml";
btData = "version=\"1.0\ "";
hr1 =
Root->createProcessi ngInstruction(b tTarget.Detach( ),btData.Detach (),&xmlPrsInst) ;
hr1 = Root->appendChild(xm lPrsInst,&EvenN odeAddress);
xmlPrsInst.Rele ase();
EvenNodeAddress .Release();
//end of new
//RootElement
hr1 =
Root->createNode(CCo mVariant(NODE_E LEMENT),CComBST R("Employee"),N ULL,&node);
hr1 = Root->appendChild(no de,&OddNodeAddr ess);
node.Release();


//ParentElement
hr1 =
Root->createNode(CCo mVariant(NODE_E LEMENT),CComBST R("EmployeeDeta ils"),NULL,&nod e);
hr1 = OddNodeAddress->appendChild(no de,&EvenNodeAdd ress);
node.Release();
OddNodeAddress. Release();

//First ChildElement
hr1 =
Root->createNode(CCo mVariant(NODE_E LEMENT),CComBST R("EmpID"),NULL ,&node);
node->put_text(CComB STR(chrEmpID));
hr1 = EvenNodeAddress->appendChild(no de,&OddNodeAddr ess);
node.Release();
OddNodeAddress. Release();
//Second ChildElement
hr1 =
Root->createNode(CCo mVariant(NODE_E LEMENT),CComBST R("EmpName"),NU LL,&node);
node->put_text(CComB STR(chrEmpName) );
hr1 = EvenNodeAddress->appendChild(no de,&OddNodeAddr ess);
node.Release();
OddNodeAddress. Release();

//Third ChildElement
hr1 =
Root->createNode(CCo mVariant(NODE_E LEMENT),CComBST R("EmpAge"),NUL L,&node);
char strEmpAge[10];

itoa(intEmpAge, strEmpAge,10);
node->put_text(CComB STR(strEmpAge)) ;
hr1 = EvenNodeAddress->appendChild(no de,&OddNodeAddr ess);
node.Release();
OddNodeAddress. Release();

//Forth ChildElement
hr1 =
Root->createNode(CCo mVariant(NODE_E LEMENT),CComBST R("EmpAddress") ,NULL,&node);
node->put_text(CComB STR(chrEmpAddre ss));
hr1 = EvenNodeAddress->appendChild(no de,&OddNodeAddr ess);
node.Release();
OddNodeAddress. Release();

hr1=Root->save(CComVaria nt("C:\\temp\\v c.xml"));
//Root.Release();
node.Release();
OddNodeAddress. Release();
EvenNodeAddress .Release();
CoUninitialize( );

//bFunctionStatus = true;
//return Root;
return true;
}
END OF CODE 2]############### ############### ##
I am unable to send data from my C++ application to my webservice
which accepts data in xmldocument form.

Any help or suggesting in this regards? you could also reply to me
on my mail address: ag***@hotmail.c om

Dec 28 '05 #1
0 1825

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

Similar topics

6
768
by: Davie | last post by:
I want to authorise a user of a web service by using the AuthHeaderValue for some reason I keep getting a null reference exception when I try to run the following code: It seems to work fine on a .NET Framework application, but just not on the .NET CF version. Can anyone suggest anything that might be wrong with the code? (I could post the app and webservice, but i was hoping that you might have noticed something from the supplied...
2
3581
by: ALI-R | last post by:
Hi All, I have a webservice on a win 2003 server and I'm trying to call it from another win2003 server which is hosting my sharepoint portal server. I am trying to call that webservice from a webpart but I get this error which says : System.Net.WebException: The request failed with HTTP status 401: Unauthorized. at RSTreeWebPart.RSTree.reportsList() at RSTreeWebPart.RSTree.RenderWebPart(HtmlTextWriter output)
1
1692
by: 'Mani | last post by:
Hi All, I have an application written in C++ which uses GSoap to make webservice requests. The application works fine in Windows 2003 and Windows XP. But when we tried to run the application from a Windows 2000 SP4 machine, it crashes while making a webservice call. Have anybody faced this issue earlier? Is there any way to solve this?
5
1360
by: berto | last post by:
Hi all, I've been searching around for a long time to solve a question I have, and haven't found a solution yet, hope some of you can help me. The problem is that I have a server which has two IP addresses, and a web application which consumes webservices from other servers. The thing is that, in my app., I want to be able to select which IP address, from the two possible, is used as source IP whenever I make a call to a webservice. Is...
0
1208
by: acteon | last post by:
Hello, I have a webservice written in C sharp that is using an IBM provided DLL. The project that installs my webservice has a .MSM merge module file for that DLL. When the .MSI file generated is runned, It only installs dll's on the target webserver. I need it to install the normal .ASMX files & webconfig files that are normally part of the webservice.
7
5618
by: christian13467 | last post by:
Hi, I'm using ASP.Net 2.0 with IIS 6.0 on windows server 2003 sp1. Calling a commandline program or a cmd file using Process.Start inside a webservice method. The call to Process.Start returns once after restarting the iis. A second call to my webservice method never returns. I found some post wich where fixed checking access rights. I added ASPNET to administrators group with no success.
0
788
by: jlawson | last post by:
I have written a WebService and it works fine on the machine that I wrote it on. I would like to place this WebService on another XP Pro machine (brand new install, out of the box). What do I need to install on this new machine that will allow the WebService to function without installing Visual Studios 2003? Rumor has it that I need WSE1, WSE2, and dotnetfx. So I installed all three. Didn't work. Need Help! John
0
1345
by: screen.one | last post by:
Hi (Framework 1.1, Webservice platform Windows 2003 Server) I have a little windows service which is supposed to call one or more webservices at regular intervals. Recently this service has started to fail more and more often until now, when it won't run at all. I've managed to locate the problem, and it seems that when it makes an asyncronous webservice call, it doesn't get any notification when the
6
6266
by: Doug Ferguson | last post by:
I am using a webservice client that was created from a WSDL file in .Net 1.1. The client ALWAYS works the first time I call it. The second call returns one of two exceptions. It either returns the error: A) The connection has been closed on a receive : Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
0
9632
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
9471
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
10302
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
10136
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9925
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8958
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
7478
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
5372
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
5501
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.