C# Web Service - Invoked from a VC++ 6.0 Client (MS-SOAP)
-
Hello, I'm a kindof newbie to SOAP, so please help me with this problem. It could be a very basic one, but I'm trying to figure out what's wrong in this, since a couple of days now! The webservice runs fine when invoked from IE, but from my app, it doesn't receive the parameter. Here's my setup information & code segments to help you help me: :-) * Server End: Windows Server 2003 Enterprise Edition, IIS 6.0, VS.NET 2003 * Web Service: The C# web service is just supposed to receive a string and return a string.
/////////////////// Code Segment: [WebMethod (CacheDuration = 30)] public string GreetMe(string sName) { return ("Hello " + sName + "!"); } ///////////////////
* At the Client End: VC++ (MFC) - Using MS-SOAP Toolkit 3.0 I am not using a WSDL file, and I am directly trying to invoke the Web Service. Code:
/////////////////////////////////////// void CSOAPClientDlg::OnBtnGetString() /// Gets a string and sends it to the webservice GreetMe()! { //{ try { ISoapConnectorPtr psmConnector = NULL; ISoapSerializerPtr psmSerializer = NULL; ISoapReaderPtr psmReader = NULL; //////// CString csName; psmConnector.CreateInstance(__uuidof(HttpConnector30)); psmConnector->Property["EndPointURL" = "http://172.16.1.95/WebServices/ws1/Service1.asmx"; psmConnector->Connect(); psmConnector->Property["SoapAction"] = "http://172.16.1.95/WebServices/ws1/GreetMe"; psmConnector->BeginMessage(); psmSerializer.CreateInstance(__uuidof(SoapSerializer30)); psmSerializer->Init(_variant_t((IUnknown *) psmConnector->InputStream)); psmSerializer->StartEnvelope("", "STANDARD", ""); psmSerializer->StartBody("STANDARD"); psmSerializer->StartElement("GreetMe", "http://172.16.1.95/WebServices/ws1/", "", ""); psmSerializer->StartElemen("sName", "", "STANDARD", ""); GetDlgItem(IDC_TXT_GREET)->GetWindowText(csName); psmSerializer->WriteString(csName.AllocSysString()); psmSerializer->EndElement(); psmSerializer->EndElement(); psmSerializer->EndBody(); psmSerializer->EndEnvelope(); psmConnector->EndMessage(); psmReader.CreateInstance(__uuidof(SoapReader30)); psmReader->Load(_variant_t((IUnknown *) psmConnector->OutputStream), ""); GetDlgItem(IDC_TXT_XML)->SetWindowText((const char *)psmReader->RpcResult->xml); GetDlgItem(IDC_TXT_GREET)->SetWindowText((const char *) psmReader->RpcResult->text); psmConnector.Release(); psm
-
Hello, I'm a kindof newbie to SOAP, so please help me with this problem. It could be a very basic one, but I'm trying to figure out what's wrong in this, since a couple of days now! The webservice runs fine when invoked from IE, but from my app, it doesn't receive the parameter. Here's my setup information & code segments to help you help me: :-) * Server End: Windows Server 2003 Enterprise Edition, IIS 6.0, VS.NET 2003 * Web Service: The C# web service is just supposed to receive a string and return a string.
/////////////////// Code Segment: [WebMethod (CacheDuration = 30)] public string GreetMe(string sName) { return ("Hello " + sName + "!"); } ///////////////////
* At the Client End: VC++ (MFC) - Using MS-SOAP Toolkit 3.0 I am not using a WSDL file, and I am directly trying to invoke the Web Service. Code:
/////////////////////////////////////// void CSOAPClientDlg::OnBtnGetString() /// Gets a string and sends it to the webservice GreetMe()! { //{ try { ISoapConnectorPtr psmConnector = NULL; ISoapSerializerPtr psmSerializer = NULL; ISoapReaderPtr psmReader = NULL; //////// CString csName; psmConnector.CreateInstance(__uuidof(HttpConnector30)); psmConnector->Property["EndPointURL" = "http://172.16.1.95/WebServices/ws1/Service1.asmx"; psmConnector->Connect(); psmConnector->Property["SoapAction"] = "http://172.16.1.95/WebServices/ws1/GreetMe"; psmConnector->BeginMessage(); psmSerializer.CreateInstance(__uuidof(SoapSerializer30)); psmSerializer->Init(_variant_t((IUnknown *) psmConnector->InputStream)); psmSerializer->StartEnvelope("", "STANDARD", ""); psmSerializer->StartBody("STANDARD"); psmSerializer->StartElement("GreetMe", "http://172.16.1.95/WebServices/ws1/", "", ""); psmSerializer->StartElemen("sName", "", "STANDARD", ""); GetDlgItem(IDC_TXT_GREET)->GetWindowText(csName); psmSerializer->WriteString(csName.AllocSysString()); psmSerializer->EndElement(); psmSerializer->EndElement(); psmSerializer->EndBody(); psmSerializer->EndEnvelope(); psmConnector->EndMessage(); psmReader.CreateInstance(__uuidof(SoapReader30)); psmReader->Load(_variant_t((IUnknown *) psmConnector->OutputStream), ""); GetDlgItem(IDC_TXT_XML)->SetWindowText((const char *)psmReader->RpcResult->xml); GetDlgItem(IDC_TXT_GREET)->SetWindowText((const char *) psmReader->RpcResult->text); psmConnector.Release(); psm
Server side seems OK. You'd get better reply in VC forum. Have you tried to find any sample in internet which consume web service from VC6 with Soap Toolkit? I've used it in VB6 and it doesn't bother at all. Mazy
"One who dives deep gets the pearls,the burning desire for realization brings the goal nearer." - Babuji -
Server side seems OK. You'd get better reply in VC forum. Have you tried to find any sample in internet which consume web service from VC6 with Soap Toolkit? I've used it in VB6 and it doesn't bother at all. Mazy
"One who dives deep gets the pearls,the burning desire for realization brings the goal nearer." - BabujiMazy, Thanks for your reply! I was not able to find any sample on the net which consumed web services from VC++ 6.0, hence I had to post my query - Hoping someone would've worked on it! :( I am still looking harder for such samples. Everything in the code seems right... But the parameter is not being received at the server end! :confused: Thanks anyway, Rgds, Nirav Doshi * Don't wish it was easier, wish you were better! *
-
Hello, I'm a kindof newbie to SOAP, so please help me with this problem. It could be a very basic one, but I'm trying to figure out what's wrong in this, since a couple of days now! The webservice runs fine when invoked from IE, but from my app, it doesn't receive the parameter. Here's my setup information & code segments to help you help me: :-) * Server End: Windows Server 2003 Enterprise Edition, IIS 6.0, VS.NET 2003 * Web Service: The C# web service is just supposed to receive a string and return a string.
/////////////////// Code Segment: [WebMethod (CacheDuration = 30)] public string GreetMe(string sName) { return ("Hello " + sName + "!"); } ///////////////////
* At the Client End: VC++ (MFC) - Using MS-SOAP Toolkit 3.0 I am not using a WSDL file, and I am directly trying to invoke the Web Service. Code:
/////////////////////////////////////// void CSOAPClientDlg::OnBtnGetString() /// Gets a string and sends it to the webservice GreetMe()! { //{ try { ISoapConnectorPtr psmConnector = NULL; ISoapSerializerPtr psmSerializer = NULL; ISoapReaderPtr psmReader = NULL; //////// CString csName; psmConnector.CreateInstance(__uuidof(HttpConnector30)); psmConnector->Property["EndPointURL" = "http://172.16.1.95/WebServices/ws1/Service1.asmx"; psmConnector->Connect(); psmConnector->Property["SoapAction"] = "http://172.16.1.95/WebServices/ws1/GreetMe"; psmConnector->BeginMessage(); psmSerializer.CreateInstance(__uuidof(SoapSerializer30)); psmSerializer->Init(_variant_t((IUnknown *) psmConnector->InputStream)); psmSerializer->StartEnvelope("", "STANDARD", ""); psmSerializer->StartBody("STANDARD"); psmSerializer->StartElement("GreetMe", "http://172.16.1.95/WebServices/ws1/", "", ""); psmSerializer->StartElemen("sName", "", "STANDARD", ""); GetDlgItem(IDC_TXT_GREET)->GetWindowText(csName); psmSerializer->WriteString(csName.AllocSysString()); psmSerializer->EndElement(); psmSerializer->EndElement(); psmSerializer->EndBody(); psmSerializer->EndEnvelope(); psmConnector->EndMessage(); psmReader.CreateInstance(__uuidof(SoapReader30)); psmReader->Load(_variant_t((IUnknown *) psmConnector->OutputStream), ""); GetDlgItem(IDC_TXT_XML)->SetWindowText((const char *)psmReader->RpcResult->xml); GetDlgItem(IDC_TXT_GREET)->SetWindowText((const char *) psmReader->RpcResult->text); psmConnector.Release(); psm
Hello, I got the solution to the problem I was facing. It was expecting a NAMESPACE parameter which I was not providing it. So by changing the following:
psmSerializer->StartElement("GreetMe", "http://172.16.1.95/WebServices/ws1/", "STANDARD", "mns"); psmSerializer->StartElement("nFirstNo", "", "STANDARD", "mns");
After I gave the last parameter "mns" for the namespace, the code worked as expected! :-):-O Posting this, just in case anyone had (or may have) a similar problem. Righto! Rgds, Nirav * Don't wish it was easier, wish you were better! *