0 Replies Latest reply on Nov 7, 2013 1:07 AM by Oscar Manuel Juarez Villafaña

    problem with consuming of .net web services with utl_http

    Oscar Manuel Juarez Villafaña

      In several examples posted in the web, for consuming .net web people shows how to do that. But in my case consuming services with utl_http do not work. I Don't understand why i get error http:500 or http:400. the first error appears when I don't use some characters like ñ or ú in the message. But .net web service told me something like this:

       

      <soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>System.Web.Services.Protocols.SoapException: Server was unable to read

      request. ---&gt; System.InvalidOperationException: Request format is invalid: Missing required soap:Envelope element.\r\n   at System.Web.Services.Protocols

       

      And the http-400 error is the answer from the server when i send messages with ñ, ó, ú etc.

       

      I have web services developed with jdeveloper and deployed in weblogic servers and works well with same type of invocation, please help me !!

       

      Some example code:

       

      Declare 

       

        input_envelope varchar2(32767); 

        http_req utl_http.req; 

        http_resp utl_http.resp; 

        resp sys.xmltype; 

        wsdl_url varchar2(200):='http://www.webservicex.net/RssToHTML.asmx'; 

        soap_act_url varchar2(200):='"http://www.webserviceX.NET/GetHTML"'; 

       

        Begin

         

        input_envelope := 

       

        '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' || CHR(13) ||    

          '<soap:Body xmlns:ns1="http://www.webserviceX.NET">' || CHR(13) ||

            '<ns1:gethtml>' || CHR(13) || 

              '<ns1:rssurl>TEST</ns1:rssurl>' || CHR(13) ||

            '</ns1:gethtml>' || CHR(13) ||

          '</soap:Body>' || CHR(13) ||

        '</soap:Envelope>';

         

        http_req := utl_http.begin_request(WSDL_URL, 'POST',utl_http.HTTP_VERSION_1_1); 

        dbms_output.put_line(1);

        utl_http.set_header(http_req, 'Content-Type', 'text/xml; charset=utf-8');

        dbms_output.put_line(2); 

        utl_http.set_header(http_req, 'Content-Length', LENGTH(input_envelope));

        dbms_output.put_line(3); 

        utl_http.set_header(http_req, 'SOAPAction', soap_act_url);

        dbms_output.put_line(4);   

        utl_http.write_text(http_req, input_envelope);

        dbms_output.put_line(5); 

        http_resp := utl_http.get_response(http_req);

        dbms_output.put_line(6); 

        utl_http.read_text(http_resp, input_envelope);

        dbms_output.put_line(7);     

        utl_http.end_response(http_resp);

         

      End; 

       

      using traces to see post and response:

       

      post:

       

      POST /RssToHTML.asmx HTTP/1.1\r\nHost: www.webservicex.net\r\nContent-Type: text/xml; charset=utf-8\r\nContent-Length: 372\r\nSOAPAction: htt
      p://www.webserviceX.NET/GetHTML\r\n\r\n

      <?xml version=\"1.0\" encoding=\"utf-8\"?> \n <soap:envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://ww
      w.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"> \n <soap:body>\n <gethtml xmlns=\"http://www.webserviceX.NET\"> 
      \n <rssurl>PRUEBA</rssurl> \n </gethtml>\n </soap:body> \n </soap:envelope>

       

      response:

       

      HTTP/1.1 500 Internal Server Error\r\nCache-Control: private\r\nContent-Length: 799\r\nContent-Type: text/xml; charset=utf-8\r\nServer: Micros
      oft-IIS/7.0\r\nX-AspNet-Version: 4.0.30319\r\nX-Powered-By: ASP.NET\r\nDate: Wed, 06 Nov 2013 23:44:08 GMT\r\n\r\n<?xml version=\"1.0\" encoding=\"utf-8\"?><
      soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/
      2001/XMLSchema\"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>System.Web.Services.Protocols.SoapException: Server was unable to read
      request. ---&gt; System.InvalidOperationException: Request format is invalid: Missing required soap:Envelope element.\r\n at System.Web.Services.Protocols
      .SoapServerProtocol.ReadParameters()\r\n --- End of inner exception stack trace ---\r\n at System.Web.Services.Protocols.SoapServerProtocol.ReadParameter
      s()\r\n at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope>