0

Iam trying to call a C# DotNet 2003 webservice from Visual C++ 6 app (used win32 console, mfc, atl_mfc dll) using Soap toolkit 3. The webservice takes a String input parameter and returns a String. The input parameter I pass through C++ is always recieved as NULL in C# webservice while the output is working fine and it is returned back in C++.

I have even tried with wsp wizard using atl_mfc dll and vb GUI but input always failed. It didn't give any error either. It will give an error when I output, input parameter as it is without appending to a string, then it will say Invalid pointer error in C++ app. Plz anybody can help in this regard. A bundle of thanks.

My C# webservice code is as, it is a simple ASP.NET web service generated through VS.NET 2003:

[WebMethod]
public string TestMethod(string input)
{
return "Hello World"+input;
}
My C++ code is as:
#include <stdio.h>
#import "msxml4.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;
 
ISoapSerializerPtr Serializer;
ISoapReaderPtr Reader;
ISoapConnectorPtr Connector;
// Connect to the service
Connector.CreateInstance(__uuidof(HttpConnector30));
Connector->Property["EndPointURL"] = "[URL]http://localhost/WS/Service1.asmx";
Connector->Connect();
// Begin message
Connector->Property["SoapAction"] = "[URL]http://tempuri.org/TestMethod";
Connector->BeginMessage();
// Create the SoapSerializer
Serializer.CreateInstance(__uuidof(SoapSerializer30));
// Connect the serializer to the input stream of the connector
Serializer->Init(_variant_t((IUnknown*)Connector->InputStream));
// Build the SOAP Message
Serializer->StartEnvelope("","","");
Serializer->StartBody("");
Serializer->StartElement("TestMethod","http://tempuri.org/TestMethod","","m");
Serializer->StartElement("input","","","");
Serializer->WriteString("input");
Serializer->EndElement();
Serializer->EndElement();
Serializer->EndBody();
Serializer->EndEnvelope();
 
// Send the message to the web service
Connector->EndMessage(); 
// Let us 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: %s\n", (const char *)Reader->RpcResult->text);
_bstr_t res = Reader->RpcResult->text;
2
Contributors
1
Reply
3
Views
10 Years
Discussion Span
Last Post by yogesh.chhabra
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.