Loading ...
Sorry, an error occurred while loading the content.

6038Newbee needs help with perl soap lite service and c++ .net client. (hmh)

Expand Messages
  • sarah1878carter
    Oct 24, 2007
    • 0 Attachment
      I have tried just about everything I can think of to get this simple
      soap service to work. I just can't make it work. It's my first time
      trying this. It's my "hello world" version of my little project. I
      have included the code I have so far below. It's all examples found
      in the docs. If you can help, I would be ever so grateful.

      I am using the Microsoft visual studio 2005 programming software,
      visual c++, and the .net framework (managed code).

      My c++ .net framework client is sending the two variables
      successfully to the perl web service. The problem is that nothing is
      returning. No matter how I tweak the code, nothing seems to work out
      for me.

      I see quite a few examples for c# but nothing for the c++ .net
      framework. I am in such distress over this; I'm not sure what to do
      with myself. I could really use a little rescuing.

      Here is the code for the perl soap lite web service:

      #!/usr/bin/perl -w -t
      #!/usr/local/bin/perl -w -t

      #define the path to this script
      #http://www.htpad.com/cgi-bin/gamer/soapRelay.cgi

      use SOAP::Transport::HTTP;

      SOAP::Transport::HTTP::CGI
      -> dispatch_to('Example1')
      -> handle;

      package Example1;
      sub Add {
      #get the two variables we sent to this soap server
      my ($self, $temp1, $temp2) = @_ ;
      #send a test email - data was sent correctly - email shows
      both variables
      &sendTheEmail($temp1, $temp2);
      #return the result - does not return! - I do not know why
      #I tried using the decimal type, the int type, and the string
      type.
      return SOAP::Data-> name('temp0')
      -> type('decimal')
      -> uri('urn:Example1')
      -> value(42);
      }



      Here is the code for the c++ .net framework (managed code) client:

      #include "stdafx.h"

      #using <System.Web.Services.dll>
      #using <System.Xml.dll>
      #using <System.dll>

      using namespace System::Diagnostics;
      using namespace System::Xml::Serialization;
      using namespace System;
      using namespace System::Web::Services::Protocols;
      using namespace System::Web::Services;

      namespace MyMath
      {

      [System::Web::Services::WebServiceBindingAttribute
      (Name="MyMathSoap",Namespace="urn:Example1")]
      public ref class MyMath: public
      System::Web::Services::Protocols::SoapHttpClientProtocol
      {
      public:

      [System::Diagnostics::DebuggerStepThroughAttribute]
      MyMath()
      {
      this->Url =
      "http://www.htpad.com/cgi-
      bin/gamer/soapRelay.cgi";
      }


      [System::Diagnostics::DebuggerStepThroughAttribute]

      [System::Web::Services::Protocols::SoapDocumentMethodAttribute
      ("urn:Example1/Add",
      RequestNamespace="urn:Example1",
      ResponseNamespace="urn:Example1",

      Use=System::Web::Services::Description::SoapBindingUse::Litera
      l,

      ParameterStyle=System::Web::Services::Protocols::SoapParameter
      Style::Wrapped)]
      int Add( int num1, int num2 )
      {
      array<Object^>^temp0 = {num1,num2};
      array<Object^>^results = this->Invoke( "Add",
      temp0 );
      //I tried both lines below.
      return *dynamic_cast<int^>(results[0]);
      //return (int) results[0];
      }


      [System::Diagnostics::DebuggerStepThroughAttribute]
      System::IAsyncResult^ BeginAdd( int num1, int num2,
      System::AsyncCallback^ callback, Object^ asyncState )
      {
      array<Object^>^temp1 = {num1,num2};
      return this->BeginInvoke( "Add", temp1,
      callback, asyncState );
      }


      [System::Diagnostics::DebuggerStepThroughAttribute]
      int EndAdd( System::IAsyncResult^ asyncResult )
      {
      array<Object^>^results = this->EndInvoke(
      asyncResult );
      return *dynamic_cast<int^>(results[ 0 ]);
      }

      }; //end of class
      } //end of namespace

      void main()
      {
      Console::WriteLine
      ("start: hit enter");
      Console::ReadLine();

      Console::WriteLine
      ("Calling the big SOAP Server to say hello");
      MyMath::MyMath^ callMyMath = gcnew MyMath::MyMath();

      //my soap service gets the two variables but does not return
      a value. thus, the below line is always 0.
      Console::WriteLine
      ("The SOAP Server says: " + callMyMath->Add(14, 21));

      Console::WriteLine
      ("end: hit enter");
      Console::ReadLine();
      }

      I would be ever so grateful for any help...:)