1

我有以下 REST Web 服务:

<WebInvoke(Method:="GET", BodyStyle:=WebMessageBodyStyle.WrappedRequest,
RequestFormat:=WebMessageFormat.Json, ResponseFormat:=WebMessageFormat.Json, UriTemplate:="/GetConfigValue")>
Function GetConfigValue(ByVal ConfigSection As String) As Stream Implements IMediaManagerService.GetConfigValue

    WebOperationContext.Current.OutgoingResponse.ContentType = "application/json; charset=utf-8"

    Dim client As New System.Net.Mail.SmtpClient
    Dim host As String = client.Host
    Dim port As String = client.Port.ToString()

    'Return host
    Return New MemoryStream(Encoding.UTF8.GetBytes(host))

End Function

在 PL/SQL 中,我使用此服务:

    FUNCTION GetWebConfig (p_AppUrl VARCHAR2, p_ConfigSection VARCHAR2)
       RETURN VARCHAR2
    AS

   l_param_list      VARCHAR2 (512);

   l_http_request    UTL_HTTP.req;
   l_http_response   UTL_HTTP.resp;

   l_response_text   VARCHAR2 (32767);
BEGIN
   -- service's input parameters
   l_param_list := 'ConfigSection=HOSTSMTP';

   -- preparing Request...
   l_http_request :=
      UTL_HTTP.begin_request (
         'http://localhost/services/myservices.svc/GetConfigValue',
         'GET',
         'HTTP/1.1');

   -- ...set header's attributes
   UTL_HTTP.set_header (l_http_request,
                        'Content-Type',
                        'application/json; charset=utf-8');
   UTL_HTTP.set_header (l_http_request,
                        'Content-Length',
                        LENGTH (l_param_list));

   -- ...set input parameters
   UTL_HTTP.write_text (l_http_request, l_param_list);

   -- get Response and obtain received value
   l_http_response := UTL_HTTP.get_response (l_http_request);

   UTL_HTTP.read_text (l_http_response, l_response_text);

   DBMS_OUTPUT.put_line (l_response_text);

   -- finalizing
   UTL_HTTP.end_response (l_http_response);
EXCEPTION
   WHEN UTL_HTTP.end_of_body
   THEN
      UTL_HTTP.end_response (l_http_response);


    END;

但由于某种原因,响应返回 404 / Not Found

我在 FIDDLER 中执行了链接: http:// localhost /services/myservices.svc/GetConfigValue ,它运行良好,但使用它或从 pl/sql 调用它返回找不到。

4

0 回答 0