T
Tony C
Hi all I think I am going to go mad if I cant solve this problem.
Basically I have created a simple .NET Web Service that takes a string
as a parameter as follows.
<WebMethod()> _
Public Function ReturnString(ByVal INPUT As String) as String
Return "You passed in:" & INPUT
End Function
Then I created a simple console Application that uses the SOAP toolkit
ot call it as follows
#include "stdafx.h"
#include <stdio.h>
#include "atlbase.h"
#import <msxml4.dll>
using namespace MSXML2;
#import "C:\Program Files\Common Files\MSSoap\Binaries\mssoap30.dll" \
exclude("IStream", "IErrorInfo", "ISequentialStream",
"_LARGE_INTEGER", \
"_ULARGE_INTEGER", "tagSTATSTG", "_FILETIME")
using namespace MSSOAPLib30;
void ReturnInput();
int main(int argc, char* argv[])
{
// Initialise COM and call our Web Service Method
CoInitialize(NULL);
ReturnInput();
CoUninitialize();
return 0;
}
void ReturnInput()
{
// SOAP handles for HTTP GET
ISoapSerializerPtr Serializer;
ISoapReaderPtr Reader;
ISoapConnectorPtr Connector;
HRESULT hr = S_OK;
// 1) Create a HTTP connector object, set a reference to the WSDL
contract and connect
hr = Connector.CreateInstance(__uuidof(HttpConnector30));
Connector->Property[_T("EndPointURL")] =
_T("http://localhost/Test/TestSOAP.asmx?WSDL");
hr = Connector->Connect();
// 2) Set the SOAP action and create an instance of the SOAP
serialiser class
Connector->Property[_T("SoapAction")] =
_T("http://tempuri.org/Test/TestSOAP/ReturnString");
hr = Connector->BeginMessage();
hr = Serializer.CreateInstance(__uuidof(SoapSerializer30));
hr = Serializer->Init(_variant_t((IUnknown*)Connector->InputStream));
// 3) Build up the actual SOAP XML message for the Web Service to
match the WSDL file
// (N.B. See the test page for the service which shows you the SOAP
Request to build)
hr = Serializer->StartEnvelope(_T("soap"),_T("NONE"),_T(""));
hr = Serializer->StartBody(_T(""));
hr = Serializer->StartElement(_T("ReturnString"),_T("http://localhost/Test/TestSOAP/"),
_T("NONE"),_T(""));
//Parameter
hr = Serializer->StartElement(_T("INPUT"),_T(""),
_T("NONE"),_T(""));
hr = Serializer->WriteString("SomeTest Input");
hr = Serializer->EndElement();
hr = Serializer->EndElement();
hr = Serializer->EndBody();
hr = Serializer->EndEnvelope();
hr = Connector->EndMessage();
// 4) Create an instance of the SOAP reader class, and load the
resulting
// stream that is returned into an XMLDom object
hr = Reader.CreateInstance(__uuidof(SoapReader30));
hr = Reader->Load(_variant_t((IUnknown*)Connector->OutputStream),
_T(""));
CComQIPtr<IXMLDOMDocument2> spResponseXMLDOM;
spResponseXMLDOM = Reader->Dom;
// 5) Print the SOAP repsonse out the console, but we have an XMLDOM
object
// at this point thatwe can manipulate and traverse using the
methods
USES_CONVERSION;
printf(_T("Response: %s\n"), (const
char*)W2A(spResponseXMLDOM->xml));
printf(_T("\n\nPress Enter to continue..."));
getchar();
}
The problem is that the parameters are not getting passed to the .NET
Web Service at all, and i am really confused as to why?
Any ideas would be greatly appreciated
Operating System: Windows XP (SP1)
Development Tool: Microsoft Visual Studio .NET 2003 Enterprise
Architect
SOAP Toolkit: Microsoft SOAP Toolkit v3.0
Basically I have created a simple .NET Web Service that takes a string
as a parameter as follows.
<WebMethod()> _
Public Function ReturnString(ByVal INPUT As String) as String
Return "You passed in:" & INPUT
End Function
Then I created a simple console Application that uses the SOAP toolkit
ot call it as follows
#include "stdafx.h"
#include <stdio.h>
#include "atlbase.h"
#import <msxml4.dll>
using namespace MSXML2;
#import "C:\Program Files\Common Files\MSSoap\Binaries\mssoap30.dll" \
exclude("IStream", "IErrorInfo", "ISequentialStream",
"_LARGE_INTEGER", \
"_ULARGE_INTEGER", "tagSTATSTG", "_FILETIME")
using namespace MSSOAPLib30;
void ReturnInput();
int main(int argc, char* argv[])
{
// Initialise COM and call our Web Service Method
CoInitialize(NULL);
ReturnInput();
CoUninitialize();
return 0;
}
void ReturnInput()
{
// SOAP handles for HTTP GET
ISoapSerializerPtr Serializer;
ISoapReaderPtr Reader;
ISoapConnectorPtr Connector;
HRESULT hr = S_OK;
// 1) Create a HTTP connector object, set a reference to the WSDL
contract and connect
hr = Connector.CreateInstance(__uuidof(HttpConnector30));
Connector->Property[_T("EndPointURL")] =
_T("http://localhost/Test/TestSOAP.asmx?WSDL");
hr = Connector->Connect();
// 2) Set the SOAP action and create an instance of the SOAP
serialiser class
Connector->Property[_T("SoapAction")] =
_T("http://tempuri.org/Test/TestSOAP/ReturnString");
hr = Connector->BeginMessage();
hr = Serializer.CreateInstance(__uuidof(SoapSerializer30));
hr = Serializer->Init(_variant_t((IUnknown*)Connector->InputStream));
// 3) Build up the actual SOAP XML message for the Web Service to
match the WSDL file
// (N.B. See the test page for the service which shows you the SOAP
Request to build)
hr = Serializer->StartEnvelope(_T("soap"),_T("NONE"),_T(""));
hr = Serializer->StartBody(_T(""));
hr = Serializer->StartElement(_T("ReturnString"),_T("http://localhost/Test/TestSOAP/"),
_T("NONE"),_T(""));
//Parameter
hr = Serializer->StartElement(_T("INPUT"),_T(""),
_T("NONE"),_T(""));
hr = Serializer->WriteString("SomeTest Input");
hr = Serializer->EndElement();
hr = Serializer->EndElement();
hr = Serializer->EndBody();
hr = Serializer->EndEnvelope();
hr = Connector->EndMessage();
// 4) Create an instance of the SOAP reader class, and load the
resulting
// stream that is returned into an XMLDom object
hr = Reader.CreateInstance(__uuidof(SoapReader30));
hr = Reader->Load(_variant_t((IUnknown*)Connector->OutputStream),
_T(""));
CComQIPtr<IXMLDOMDocument2> spResponseXMLDOM;
spResponseXMLDOM = Reader->Dom;
// 5) Print the SOAP repsonse out the console, but we have an XMLDOM
object
// at this point thatwe can manipulate and traverse using the
methods
USES_CONVERSION;
printf(_T("Response: %s\n"), (const
char*)W2A(spResponseXMLDOM->xml));
printf(_T("\n\nPress Enter to continue..."));
getchar();
}
The problem is that the parameters are not getting passed to the .NET
Web Service at all, and i am really confused as to why?
Any ideas would be greatly appreciated
Operating System: Windows XP (SP1)
Development Tool: Microsoft Visual Studio .NET 2003 Enterprise
Architect
SOAP Toolkit: Microsoft SOAP Toolkit v3.0