예제 #1
0
UString USOAPParser::processMessage(const UString& msg, URPCObject& object, bool& bContainsFault)
{
   U_TRACE(0, "USOAPParser::processMessage(%V,%p,%p,%b)", msg.rep, &object, &bContainsFault)

   U_INTERNAL_ASSERT(msg)

   UString retval;

   clearData();

   if (U_STRING_FIND(msg, 0, "http://schemas.xmlsoap.org/soap/envelope/") != U_NOT_FOUND)
      {
      zero();

      bContainsFault = true;

      (void) retval.assign(U_CONSTANT_TO_PARAM("<?xml version=\"1.0\" ?>"
                                               "<env:Envelope xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\">"
                                                  "<env:Header>"
                                                   "<env:Upgrade>"
                                                      "<env:SupportedEnvelope qname=\"ns1:Envelope\" xmlns:ns1=\"http://www.w3.org/2003/05/soap-envelope\"/>"
                                                   "</env:Upgrade>"
                                                  "</env:Header>"
                                                  "<env:Body>"
                                                   "<env:Fault>"
                                                      "<faultcode>env:VersionMismatch</faultcode>"
                                                      "<faultstring>Version Mismatch</faultstring>"
                                                   "</env:Fault>"
                                                  "</env:Body>"
                                               "</env:Envelope>"));
      }
   else if (parse(msg))
      {
      U_ASSERT_EQUALS(envelope.methodName.equal(U_CONSTANT_TO_PARAM("Fault")), false)

      retval = object.processMessage(envelope, bContainsFault);
      }
   else
      {
      int line = ::XML_GetCurrentLineNumber(m_parser),
          coln = ::XML_GetCurrentColumnNumber(m_parser);

      object.setFailed();

      URPCMethod::pFault->getFaultReason() = UXMLParser::getErrorMessage();

      U_INTERNAL_DUMP("UXMLParser: %V (%d,%d) ", URPCMethod::pFault->getFaultReason().rep, line, coln)

      URPCMethod::pFault->setDetail("The fault occurred near position (line: %d col: %d) within the message", line, coln);

      bContainsFault = true;
      retval         = URPCMethod::encoder->encodeFault(URPCMethod::pFault);
      }

   U_RETURN_STRING(retval);
}
예제 #2
0
   void run(int argc, char* argv[], char* env[])
      {
      U_TRACE(5, "Application::run(%d,%p,%p)", argc, argv, env)

      Action::run(argc, argv, env);

      // read stdin and scanf

      Action::processInputData(2);

      // --------------------------------------------------------------------------------------------------------------
      // configuration parameters
      // --------------------------------------------------------------------------------------------------------------
      // SUBJECT_TEMPLATE                 scanf form to extract data from mail header Subject:
      // SEARCH_ENGINE_FOLDER_SEARCH_URL  url to do query to search engine
      // --------------------------------------------------------------------------------------------------------------

      UString subj_tmpl = cfg[U_STRING_FROM_CONSTANT("SUBJECT_TEMPLATE")],
              url       = cfg[U_STRING_FROM_CONSTANT("SEARCH_ENGINE_FOLDER_SEARCH_URL")];

      uint32_t subject = U_STRING_FIND(request, 0, "Subject: ");

      if (subject == U_NOT_FOUND) U_ERROR("cannot find mail header subject on input data...");

      // scanf mail header Subject: from request
      // ----------------------------------------------------------------------------------------------------------------------------
      // "Subject: %*[^"]\"%[^"]\",  %*[^"]\"%[^"]\", %*[^"]\"%[^"]\""
      // ----------------------------------------------------------------------------------------------------------------------------
      // Subject: Re: TUnwired processo di registrazione utente residenziale con CPE:
      //              notifica produzione CPE cliente "workflow test", indirizzo installazione "Via Volturno, 12 50100 Firenze (FI)",
      //              UID "37723e2d-d052-4c13-a1e9-134563eb9666"
      // ----------------------------------------------------------------------------------------------------------------------------

      int n = U_SYSCALL(sscanf, "%S,%S,%p,%p,%p,%p", request.c_pointer(subject), subj_tmpl.data(), customer, installation, uid);

      if (n != 3) U_ERROR("scanf error on mail header subject...");

      U_INTERNAL_DUMP("sscanf() customer = %S installation = %S uid = %S", customer, installation, uid)

      // query to Search Engine

      UString body(10U + u__strlen(uid));

      body.snprintf("query=%s", uid);

      bool ok = Action::sendHttpPostRequest(url, body, "application/x-www-form-urlencoded", "1\n");

      Action::writeToSTDOUT(ok, ok);
      }