【问题标题】:peoplesoft integration with twiliopeoplesoft 与 twilio 的集成
【发布时间】:2016-02-01 17:16:46
【问题描述】:

我是 PT8.52 上的 peoplesoft 开发人员。我们正在尝试通过批处理(应用程序引擎)与 twilio 集成以进行 SMS 警报。我希望他们会提供 WSDL,这将是一个简单的集成。看起来情况并非如此。有人可以为我指出如何实现这一点的正确方向吗? 谢谢。

【问题讨论】:

    标签: twilio peoplesoft


    【解决方案1】:

    这里是 Twilio 开发者宣传员。

    Twilio 使用依赖于 HTTP 请求的 REST API。据我所知,您仍然可以将 Peoplesoft 与 REST 一起使用。快速查找让我找到了this

    也看看这篇文章,看看如何consume a REST webservice via PeopleCode

    可以在here 找到 Twilio 的 REST API 的文档。基本思想是,如果您可以发出 HTTP 请求,那么您应该能够毫无问题地使用 API。

    与往常一样,如果您需要更多帮助,请回到这里。

    HTH

    【讨论】:

      【解决方案2】:

      REST Web 服务没有用于 XML / SOAP 消息传递的 WSDL。 REST API 有时可能包含一个 swagger 文件,但即使 PeopleSoft 也不支持。

      您需要创建链接到消息对象的文档对象,手动创建服务、操作和处理程序代码。或者您可以像我一样使用 xml 消息并嵌入您的 json,Oracle 设计文档对象的方式存在一些限制。

      如果您对这些步骤有任何具体问题,我可以为您提供帮助。

      这是我在 App Engine 中执行的 REST 服务的示例。注意在 XML 中使用了 CDATA 部分,这是您放置 JSON 字符串的地方。

      /* LOGIN ********************************************************************************************/ 
      Local Message &msg_Login_Request, &msg_Login_Response; 
      Local Document &doc_Login_Request; 
      Local integer &i, &j, &errCount; 
      Local array of string &arrRows, &arrRow; 
      Local string &url_CalendarList; 
      Local boolean &nReturn; 
      Local string &Exception; 
      
      &msg_Login_Request = CreateMessage(Operation.MM_ADA_LOGIN_POST); 
      
      /* TODO: USERNAME AND PASSWORD */ 
      Local string &str_username = "MASKED"; 
      Local string &str_password = "MASKED"; 
      
      /* Build XML Document with the post string */ 
      Local XmlDoc &inxml = CreateXmlDoc(""); 
      Local XmlNode &rootNode = &inxml.CreateDocumentElement("data"); 
      Local XmlNode &cdataNode = &rootNode.AddCDataSection("{username:'" | &str_username | "',password:'" | &str_password | "'}"); 
      &rootNode.AddAttribute("psnonxml", "yes"); 
      &msg_Login_Request.SetXmlDoc(&inxml); 
      
      
      /* SET IBInfo Properties */ 
      &msg_Login_Request.IBInfo.SyncServiceTimeout = 360000; 
      &msg_Login_Request.IBInfo.ConnectorOverride = True; 
      &msg_Login_Request.IBInfo.IBConnectorInfo.ConnectorName = "HTTPTARGET"; 
      &msg_Login_Request.IBInfo.IBConnectorInfo.ConnectorClassName = "HttpTargetConnector"; 
      
      /* SET HTTP HEADERS */ 
      &nReturn = &msg_Login_Request.IBInfo.IBConnectorInfo.AddConnectorProperties("SSLProtocols", "TLSv1.2", %HttpHeader); 
      &nReturn = &msg_Login_Request.IBInfo.IBConnectorInfo.AddConnectorProperties("Content-Type", "application/json; encoding= UTF-8", %HttpHeader); 
      
      /* SET HTTP PROPERTIES */ 
      &nReturn = &msg_Login_Request.IBInfo.IBConnectorInfo.AddConnectorProperties("SOAPUpContent", "N", %HttpProperty); 
      &nReturn = &msg_Login_Request.IBInfo.IBConnectorInfo.AddConnectorProperties("Method", "POST", %HttpProperty); 
      &nReturn = &msg_Login_Request.IBInfo.IBConnectorInfo.AddConnectorProperties("URL", "https://theurl.com/path", %HttpProperty); 
      
      &msg_Login_Response = %IntBroker.ConnectorRequest(&msg_Login_Request, True); 
      
      If &msg_Login_Response.ResponseStatus = %IB_Status_Success Then 
         rem &Output = &msg_Login_Response.GetXmlDoc(); 
      Else 
         &Exception = &msg_Login_Response.IBException.ToString(); 
      End-If; 
      
      /* TODO: LOGIN RESULT CHECK */ 
      If True = True Then 
      
         /* CALENDAR LIST **************************************************************************************************/ 
         Local Message &msg_CalendarList_Request, &msg_CalendarList_Response; 
         &msg_CalendarList_Request = CreateMessage(Operation.MM_ADA_CALENDARLIST); 
      
         /* Build XML Document With the post string */ 
         Local XmlDoc &inxml_CalendarList = CreateXmlDoc(""); 
         Local XmlNode &rootNode_CalendarList = &inxml_CalendarList.CreateDocumentElement("data"); 
         Local XmlNode &cdataNode_CalendarList = &rootNode_CalendarList.AddCDataSection("{}"); 
         &rootNode_CalendarList.AddAttribute("psnonxml", "yes"); 
         &msg_CalendarList_Request.SetXmlDoc(&inxml_CalendarList); 
      
         /* SET IBInfo Properties */ 
         &msg_CalendarList_Request.IBInfo.SyncServiceTimeout = 360000; 
         &msg_CalendarList_Request.IBInfo.ConnectorOverride = True; 
         &msg_CalendarList_Request.IBInfo.IBConnectorInfo.ConnectorName = "HTTPTARGET"; 
         &msg_CalendarList_Request.IBInfo.IBConnectorInfo.ConnectorClassName = "HttpTargetConnector"; 
      
         /* SET HTTP HEADERS */ 
         &nReturn = &msg_CalendarList_Request.IBInfo.IBConnectorInfo.AddConnectorProperties("SSLProtocols", "TLSv1.2", %HttpHeader); 
         &nReturn = &msg_CalendarList_Request.IBInfo.IBConnectorInfo.AddConnectorProperties("Content-Type", "application/json; encoding= UTF-8", %HttpHeader); 
      
         /* SET HTTP PROPERTIES */ 
         &nReturn = &msg_CalendarList_Request.IBInfo.IBConnectorInfo.AddConnectorProperties("SOAPUpContent", "N", %HttpProperty); 
         &nReturn = &msg_CalendarList_Request.IBInfo.IBConnectorInfo.AddConnectorProperties("Method", "GET", %HttpProperty); 
         &url_CalendarList = "https://hiddenurl/path"; 
         &url_CalendarList = &url_CalendarList | "?fields=ActivityName,SectionMeetInstanceByActivityId.SectionMeeting.Section.Term.Siskey,StartDateTime,EndDateTime,SectionMeetInstanceByActivityId.SectionMeeting.ExamParentSectionMtg.SisKey,SectionMeetInstanceByActivityId.SectionMeeting.Section.SisKey,SectionMeetInstanceByActivityId.RoomConfiguration.Room.SisKey"; 
         &url_CalendarList = &url_CalendarList | "&filter=(ActivityTypeCode%3D%3D1%26%26SectionMeetInstanceByActivityId.SectionMeeting.IsExam%3D%3D1%26%26SectionMeetInstanceByActivityId.SectionMeeting.Section.Term.Siskey%3D%3D%271153%27)"; 
         &url_CalendarList = &url_CalendarList | "&sortOrder=&limit=100000&view=JSON"; 
      
         &nReturn = &msg_CalendarList_Request.IBInfo.IBConnectorInfo.AddConnectorProperties("URL", &url_CalendarList, %HttpProperty); 
      
         /* Copy the login cookies to this request */ 
         &msg_CalendarList_Request.IBInfo.IBConnectorInfo.Cookies = &msg_Login_Response.IBInfo.IBConnectorInfo.Cookies; 
      
         /* Invoke the method */ 
         &msg_CalendarList_Response = %IntBroker.ConnectorRequest(&msg_CalendarList_Request, True); 
      
         If &msg_CalendarList_Response.ResponseStatus = %IB_Status_Success Then 
            rem &Output = &msg_CalendarList_Response.GetXmlDoc(); 
         Else 
            &Exception = &msg_CalendarList_Response.IBException.ToString(); 
         End-If; 
      
         rem MessageBox(0, "", 0, 0, "Output: " | &Output); 
         rem MessageBox(0, "", 0, 0, "EXCEPTION: " | &Exception); 
      
         /******************************************************* 
      PARSE THE JSON STRING WITH RHINO 
      *******************************************************/ 
         /* 
      Local JavaObject &manager = CreateJavaObject("javax.script.ScriptEngineManager"); 
      Local JavaObject &engine = &manager.getEngineByName("JavaScript"); 
      
      &engine.put("json_string", "[""item1"", ""item2"", ""item3""]"); 
      
      &str_jsFunction = GetHTMLText(HTML.MM_ADA_PARSE_JSON, &msg_CalendarList_Response.GetContentString()); 
      
      &engine.eval(&str_jsFunction); 
      
      REM ** Access the value of the JavaScript variable named result; 
      Local string &result_text = &engine.get("result").toString(); 
      
      MessageBox(0, "", 0, 0, "RESULT TEXT: " | &result_text); 
      */ 
      
         /* Clear the staging table */ 
         SQLExec("TRUNCATE TABLE PS_MM_ADA_JSON_IN"); 
         &errCount = 0; 
      
         Local string &strData = Substring(&msg_CalendarList_Response.GetContentString(), Find("""" | "data" | """" | ":", &msg_CalendarList_Response.GetContentString()) + 9, Len(&msg_CalendarList_Response.GetContentString())); 
         &arrRows = Split(&strData, "],["); 
      
         For &i = 1 To &arrRows.Len 
            /* Fix NULL values */ 
            &arrRows [&i] = Substitute(&arrRows [&i], "null", """" | "null" | """"); 
            /* Remove the trailing JSON */ 
            &arrRows [&i] = Substitute(&arrRows [&i], """" | "]]}", ""); 
            /* Split the comma separated values */ 
            &arrRow = Split(&arrRows [&i], """" | "," | """"); 
            /* Remove the leading double quote */ 
            &arrRow [1] = Substring(&arrRow [1], 2, Len(&arrRow [1])); 
            /* Remove the trailing double quote */ 
            &arrRow [7] = Substring(&arrRow [7], 1, Len(&arrRow [7]) - 1); 
            /* Prepare the Date Time values */ 
            &arrRow [3] = Substitute(&arrRow [3], "T", " "); 
            &arrRow [4] = Substitute(&arrRow [4], "T", " "); 
            /* Fix remaining NULL values */ 
            For &j = 1 To &arrRow.Len 
               If &arrRow [&j] = "null" Then 
                  &arrRow [&j] = " "; 
               End-If; 
            End-For; 
            try 
               SQLExec("INSERT INTO PS_UC_ADA_JSON_IN VALUES(:1,:2,%DateTimeIn(:3),%DateTimeIn(:4),:5,:6,:7)", &arrRow [1], &arrRow [2], &arrRow [3], &arrRow [4], &arrRow [5], &arrRow [6], &arrRow [7]); 
            catch Exception &err 
               &errCount = &errCount + 1; 
               MM_ADA_TEST_WRK.LONGVALUE = MM_ADA_TEST_WRK.LONGVALUE | Char(10) | "EXCEPTION: " | &err.ToString() | Char(10); 
               MM_ADA_TEST_WRK.LONGVALUE = MM_ADA_TEST_WRK.LONGVALUE | &arrRow [1] | " , " | &arrRow [2] | " , " | &arrRow [3] | " , " | &arrRow [4] | " , " | &arrRow [5] | " , " | &arrRow [6] | " , " | &arrRow [7]; 
               MM_ADA_TEST_WRK.LONGVALUE = MM_ADA_TEST_WRK.LONGVALUE | Char(10); 
            end-try; 
         End-For; 
      
         MM_ADA_TEST_WRK.LONGVALUE = "ERRORS: " | &errCount | Char(10) | MM_ADA_TEST_WRK.LONGVALUE; 
      Else 
         /* AUTHENTICATION FAILED */ 
         MM_ADA_TEST_WRK.LONGVALUE = "AUTHENTICATION FAILED."; 
      
      End-If; 
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-05-08
        • 1970-01-01
        • 2019-08-28
        • 2017-11-29
        • 1970-01-01
        相关资源
        最近更新 更多