如果您从 WCF 服务收到响应 500(内部错误),请尝试在 WCF 服务的 web.config 中设置 includeexceptiondetailinfaults=true 。(http://msdn.microsoft.com/cs-cz/library/system.servicemodel.description.servicedebugbehavior.includeexceptiondetailinfaults(v=vs.110).aspx)
然后你会得到详细的异常(错误的肥皂动作,错误的格式......)
从 PL/SQL 调用 WCF 服务。
utl_http 但它有效。
/*
declare
p_request VARCHAR(32767);
p_plainResult VARCHAR2(32767);
begin
p_request := '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:Sum>
<tem:a>1</tem:a>
<tem:b>2</tem:b>
</tem:Sum>
</soapenv:Body>
</soapenv:Envelope>';
select callSOAPService(p_request,'http://tempuri.org/IMathService/Sum','http://localhost:51106/MathService.svc') into p_plainResult from dual;
end;
*/
create or replace function callSOAPService
(
p_plainRequest IN varchar2(20000),
p_actionName IN varchar2(1024), --SOAP Action ( in WCF, attribute [OperationContract(Action="ActionName")
p_url IN varchar2(1024),
p_userName varchar2(1024) := null,
p_password varchar2(1024) := null,
p_isAsynchronous boolean:= FALSE,
p_proxy varchar2(1024):=null,
p_transferTimeout number :=null,
)
RETURN VARCHAR2(32767)
IS
p_charset varchar2(1024) :='AL32UTF8'; --by default utf-8
p_request utl_http.req;
p_response utl_http.resp;
p_plainResponse varchar2(32767);
BEGIN
p_url := utl_url.escape(url => p_url); --escape url
if p_TransferTimeout > 0 THEN --set oracle timeout ( by defualt is 60 sec )
utl_http.set_transfer_timeout(timeout => p_transferTimeout);
END IF;
if p_proxy IS NOT NULL THEN --if proxy is provided, then set it
utl_http.set_proxy(proxy => p_proxy);
end if;
utl_http.set_response_error_check(enable => TRUE); --http status errorCheck ( 404 not found, 500 internal error...)
utl_http.set_detailed_excp_support(enable => TRUE); --detailed error stack
p_request := UTL_HTTP.begin_request(url => p_url,method => 'POST' /*u SOAP bude vzdy POST meotda*/ ,http_version => 'HTTP/1.1');
--pripravim si obalku
UTL_HTTP.set_header (r => p_request,name => 'Content-Type', value => 'text/xml');
UTL_HTTP.set_header (r => p_request,name => 'Content-Length',value => LENGTH (p_plainRequest));
UTL_HTTP.set_header (r => p_request, name => 'SOAPAction',value => p_actionName); --if status is 500 check SOAP action
UTL_HTTP.write_text(r => p_request,data => p_plainRequest);
p_response := UTL_HTTP.get_response (p_request);
if p_isAsynchronous THEN --one-way service
UTL_HTTP.end_response (p_response); --proto ukoncim request a vratim prazdno
RETURN '';
end if;
utl_http.read_text (p_response, p_plainResponse); --read response
utl_http.end_response (p_response); --close resposne
dbms_output.put_line ('Response from: ' || p_url || ' is ' || p_plainResponse); --vypisu odpoved pro kontrolu
return p_plainResponse;
EXCEPTION
when others then
dbms_output.put_line('Chyba ' || UTL_HTTP.get_detailed_sqlerrm()); --get error stack
utl_http.end_response (p_response);
END;