簡體   English   中英

如何在 WCF web 服務 ZD7EFA19FBE7D3972FD5ADB602422 中請求之前創建自定義 header

[英]How to create custom header before request in WCF web service C#

我想在 C# 中集成 bluesuit ( https://docs.bluesuit.com/?shell#send-document )。 我想通過使用 WCF 服務設置Content-TypeAuthorization Bearer將 .pdf 上傳到.pdf How to add this in header and call https://docs.bluesuit.com/?shell#send-document post method and get response and integrate bluesuit in C# with WCF?

Simply I just want to call a third party (bluesuit) post url in wcf service and get response from this third party (bluesuit) post url so how to call this third party post url in a WCF method?

提前致謝。 需要幫助請指教。

你可以這樣做:

// Code to get a static WebClient
private static WebClient GetWebClient
{
    get
    {
        var client = new WebClient
        {
            BaseAddress = "https://docs.bluesuit.com/?shell#send-document",
            UseDefaultCredentials = true
        };
        client.QueryString.Clear();
        client.Headers.Clear();
        client.Headers.Add("content-type", "application/pdf");
        return client;
    }
}

function 中的用法,您需要從 bluesuit 獲得響應:

var client = GetWebClient;
// getToken() call returns you the Token as a string
client.Headers.Set(HttpRequestHeader.Authorization, "Bearer " + getToken());
var data = "Your data goes here";
var response = client.UploadString(url, "POST", data);

根據您的用例處理響應。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM