線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:4588
推到 Plurk!
推到 Facebook!

webService THTTPReqResp使用問題.

尚未結案
stars_chen
一般會員


發表:14
回覆:35
積分:9
註冊:2006-10-29

發送簡訊給我
#1 引用回覆 回覆 發表時間:2007-11-06 13:11:30 IP:218.104.xxx.xxx 訂閱
各位大大,我現在使用THTTPReqResp元件傳送XML格式的數據集給客戶提供的一個HTTPS SERVICE上.
在跟HTTPS SERVICE連接時會報出下面ERROR MESSAGE:
A certificate is required to complete client authentication

我現在不知道應該怎麽樣來解決這個問題呢?
在網上找好久沒有找到相關的資料.有知道的大大嗎?

下面是我寫的傳送數據的function
function TDell_Frm.XMLSoapPost(HttpReqresp: THTTPReqResp; V_UrlAddress: string; v_UserID: string; v_Password: string; V_Request: string;
V_SopaAction: string; V_Proxy: string; var V_Repsonse: string; var V_msg: string): Boolean;
var
Stream: TMemoryStream;
StrStream: TStringStream;
begin
V_Repsonse := '';
V_msg := '';
Result := False;
if V_UrlAddress = '' then
begin
v_msg := 'parameter V_UrlAddress can not null!';
exit;
end;
if V_Request = '' then
begin
v_msg := 'parameter V_Request can not null!';
exit;
end;
Stream := TMemoryStream.Create;
try
HTTPReqResp.URL := V_UrlAddress; //input
HttpReqresp.UserName := v_UserID;
HttpReqresp.Password := v_Password;
HTTPReqResp.UseUTF8InHeader := True;
HTTPReqResp.SoapAction := '';
if V_Proxy <> '' then
HTTPReqResp.Proxy := V_Proxy; //inpute
HTTPReqResp.Execute(V_Request, Stream); //request input
StrStream := TStringStream.Create('');
try
StrStream.CopyFrom(Stream, 0);
V_Repsonse := StrStream.DataString; //output
Result := True;
finally
StrStream.Free;
end;
finally
Stream.Destroy;
end;
stars_chen
一般會員


發表:14
回覆:35
積分:9
註冊:2006-10-29

發送簡訊給我
#2 引用回覆 回覆 發表時間:2007-11-06 14:14:40 IP:218.104.xxx.xxx 訂閱
下面是我找到的一個VB.NET寫的FUNCTION,這個是可以執行OK的.
我看主要是下面紅色部分的寫法,怎麽用DELPHI 7中的THTTPReqResp

Function SEND_XML(ByVal STR_URL As String, _
ByVal STR_USER As String, _
ByVal STR_PWD As String, _
ByVal STR_XML As String) As Boolean
Dim errFlag As Boolean = True
Dim xmldata() As Byte = Encoding.ASCII.GetBytes(STR_XML)
Dim ur As New Uri(STR_URL)
'Below is the Credentials Portion of the Code
Dim Cred As New NetworkCredential(STR_USER, STR_PWD) 'Pass Thru the Username and Password
Dim cc As New CredentialCache
cc.Add(ur, "Basic", Cred) 'Always Use BasicType Credentials

Dim wc As New WebClient 'Web Client object
wc.Credentials = cc 'Credentials from above are added in

wc.Headers.Add("Content-Type", "text/xml") 'Add the Header
'Dim STR As Stream = wc.OpenWrite(ur.ToString())
Dim STR As Stream
Try
STR = wc.OpenWrite(ur.ToString())
STR.Write(xmldata, 0, xmldata.Length)
Catch
errFlag = False
Finally
STR.Flush()
STR.Close()
End Try
Return errFlag
End Function
taishyang
站務副站長


發表:377
回覆:5490
積分:4563
註冊:2002-10-08

發送簡訊給我
#3 引用回覆 回覆 發表時間:2007-11-16 09:36:00 IP:122.124.xxx.xxx 訂閱
您可以提供新的測試結果前輩們幫您看看
但煩請勿用[自推文]的方式讓您的文章至頂
系統時間:2024-04-20 14:39:16
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!