title: calling SOAP web service from PL/SQL
body: <p>I have a .net SOAP and I want to call it from PL/SQL</p>
  
  <pre><code>DECLARE
  
  
  -- SOAP REQUESTS/RESPONSE
     soap_req_msg    VARCHAR2 (2000);
     soap_resp_msg   VARCHAR2 (2000);
  
     -- HTTP REQUEST/RESPONSE
     http_req        UTL_HTTP.req;
     http_resp       UTL_HTTP.resp;
  
  BEGIN
     --
     -- Create SOAP request via HTTP
     --
     soap_req_msg := 
        '&lt;soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"&gt;&lt;soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"&gt;&lt;wsa:MessageID&gt;urn:uuid:1d66c9a8-b5e2-4c7a-9649-0bd63a590372&lt;/wsa:MessageID&gt;&lt;wsa:Action&gt;http://tempuri.org/IDataInterfaceService/Connect&lt;/wsa:Action&gt;&lt;wsa:To&gt;http://localhost:3038/&lt;/wsa:To&gt;&lt;/soapenv:Header&gt;&lt;soapenv:Body&gt;&lt;ns1:Connect xmlns:ns1="http://tempuri.org/"/&gt;&lt;/soapenv:Body&gt;&lt;/soapenv:Envelope&gt;';
  
     http_req :=UTL_HTTP.begin_request('http://localhost:3038/', 'POST', 'HTTP/1.1');
     UTL_HTTP.set_header (http_req, 'Accept-Encoding', 'gzip,deflate');
     UTL_HTTP.set_header (http_req, 'Content-Type', 'application/soap+xml;charset=UTF-8;action="http://tempuri.org/IDataInterfaceService/Connect"');
     UTL_HTTP.set_header (http_req, 'Content-Length', length(soap_req_msg));
     UTL_HTTP.set_header (http_req, 'Host', 'localhost:3038');
     UTL_HTTP.set_header (http_req, 'Connection', 'Keep-Alive');
     UTL_HTTP.set_header (http_req, 'User-Agent', 'Apache-HttpClient/4.1.1 (java 1.5)');
     UTL_HTTP.write_text (http_req, soap_req_msg);
  
    dbms_output.put_line(' ');
    --
     -- Invoke Request and get Response.
     --
     http_resp := UTL_HTTP.get_response(http_req);
     UTL_HTTP.read_text (http_resp, soap_resp_msg);
     UTL_HTTP.end_response (http_resp);
     DBMS_OUTPUT.put_line ('Output: ' || soap_resp_msg);
  END;
  /
  </code></pre>
  
  <p>The request is doing fine inSOAPUI. But not in the PL/SQL</p>
  
  <p>Here is the response:</p>
  
  <pre><code>Output: &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd"&gt;
  &lt;HTML&gt;&lt;HEAD&gt;&lt;TITLE&gt;Bad Request&lt;/TITLE&gt;
  &lt;META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"&gt;&lt;/HEAD&gt;
  &lt;BODY&gt;&lt;h2&gt;Bad Request - Invalid Header&lt;/h2&gt;
  &lt;hr&gt;&lt;p&gt;HTTP Error 400. The request has an invalid header name.&lt;/p&gt;
  &lt;/BODY&gt;&lt;/HTML&gt;
  </code></pre>
  
  <p>Wondering what's wrong with my header name.... Anyone can help me please? </p>
  
  <p>ADDITION: This is the RAW XML copy from SOAPUI</p>
  
  <pre><code>POST http://localhost:3038/ HTTP/1.1
  Accept-Encoding: gzip,deflate
  Content-Type: application/soap+xml;charset=UTF-8;action="http://tempuri.org/IDataInterfaceService/Connect"
  Content-Length: 441
  Host: localhost:3038
  Connection: Keep-Alive
  User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
  
  &lt;soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"&gt;&lt;soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"&gt;&lt;wsa:MessageID&gt;urn:uuid:1d66c9a8-b5e2-4c7a-9649-0bd63a590372&lt;/wsa:MessageID&gt;&lt;wsa:Action&gt;http://tempuri.org/IDataInterfaceService/Connect&lt;/wsa:Action&gt;&lt;wsa:To&gt;http://localhost:3038/&lt;/wsa:To&gt;&lt;/soapenv:Header&gt;&lt;soapenv:Body&gt;&lt;ns1:Connect xmlns:ns1="http://tempuri.org/"/&gt;&lt;/soapenv:Body&gt;&lt;/soapenv:Envelope&gt;
  </code></pre>