Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Webservice demo ?
#4
(12-29-2019, 10:01 AM)SorenJensen Wrote: Howdy Shane,

Thanks for your reply and advice. I've looked at the demo and can see how a call to a certain URL, through the ServerControllerBaseConfig setup, will be activating a named form, which of course could handle all data in and out of my database, but what I do not see from the example is how to transport the data from the client to the server and vice versa. Like the client sends a customer Id, and want the name and address information send back. Is it all done as request parameters in the http:// address line or is there another datastructure being sent along. With soap all is in the XML document being sent / received.

How do you transport reservation requests and response to and from your clients and server, this way ?

Regards
Soren
Howdy Soren,


Use the body of the request input data and the body of the response for output.

Since you are using SOAP,  you will be using XML (I assume) document type.

Below is my Viator REST API handler code (it is in C++):


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// TViatorRestAPIHandler::TViatorRestAPIHandler()
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
__fastcall TViatorRestAPIHandler::TViatorRestAPIHandler(void)
{
mFileMustExist = false;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// TViatorRestAPIHandler::Execute()
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool __fastcall TViatorRestAPIHandler::Execute ( Iw::Http::Request::THttpRequest * pRequest,
    Iw::Http::Reply::THttpReply * pReply,
                                      const System::UnicodeString strPathname,
                                      Iwapplication::TIWApplication * pSession,
                                      System::Classes::TStrings * pParams
                                  )
{
// Keep compiler happy
  NOT_USED(pParams);
  NOT_USED(pSession);
  NOT_USED(pParams);
  NOT_USED(strPathname);

  // Get Request XML
  UnicodeString strRequestXML;
  if (pRequest->Files->Count == 1)
  {
    try
    {
THttpFile * pFile = pRequest->Files->Items[0];
  TFileStream * pFileStream = new TFileStream(pFile->TempPathName,fmOpenRead | fmShareDenyNone);
  TStringStream * pXMLStream = new TStringStream;

      try
      {
        pXMLStream->CopyFrom(pFileStream,0);
        strRequestXML = pXMLStream->DataString;
      }
      __finally
      {
        delete pFileStream;
        delete pXMLStream;
      }
  }

    catch (Exception &)
    {
    // Just eat as an empty XML error will be returned
    }
  }

  // Process Viator request
  pReply->ContentType = L"application/xml";
  pReply->Code = 200;
  try
  {
    // Create Viator API object
    TViatorAPIDataModuleUniquePtr objViatorAPIDataModulePtr(new TViatorAPIDataModule(NULL));

    // Process request
    SSStringListUniquePtr objResponseListPtr;
    objViatorAPIDataModulePtr->ProcessRequest(strRequestXML,objResponseListPtr);

    // Set response
  pReply->WriteString(objResponseListPtr->Text);
  }

  catch (Exception & objException)
  {
    // Set response
  pReply->WriteString(objException.Message);
  }

  return true;
}

The key parts you want to look at is in the Execute how to fetch the body of the SOAP request and then how to write out the response.

Hope this helps.

Happy New Year!

Shane
Reply


Messages In This Thread
Webservice demo ? - by SorenJensen - 12-27-2019, 01:49 PM
RE: Webservice demo ? - by ShaneStump - 12-27-2019, 06:00 PM
RE: Webservice demo ? - by SorenJensen - 12-29-2019, 10:01 AM
RE: Webservice demo ? - by ShaneStump - 12-29-2019, 05:32 PM
RE: Webservice demo ? - by ioan - 12-30-2019, 06:20 PM
RE: Webservice demo ? - by DanBarclay - 12-30-2019, 11:49 PM
RE: Webservice demo ? - by SorenJensen - 12-31-2019, 09:18 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)