Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. C# Web Service - Invoked from a VC++ 6.0 Client (MS-SOAP)

C# Web Service - Invoked from a VC++ 6.0 Client (MS-SOAP)

Scheduled Pinned Locked Moved C#
csharpc++wcfwindows-adminxml
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nirav Doshi
    wrote on last edited by
    #1

    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
    
    M N 2 Replies Last reply
    0
    • N Nirav Doshi

      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
      
      M Offline
      M Offline
      Mazdak
      wrote on last edited by
      #2

      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

      N 1 Reply Last reply
      0
      • M Mazdak

        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

        N Offline
        N Offline
        Nirav Doshi
        wrote on last edited by
        #3

        Mazy, 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! *

        1 Reply Last reply
        0
        • N Nirav Doshi

          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
          
          N Offline
          N Offline
          Nirav Doshi
          wrote on last edited by
          #4

          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! *

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups