[WebInvoke (the UriTemplate="upload2attachment/? FileName={fileName} & amp; count={count} & amp; token={token} & amp; last={last}", BodyStyle.=WebMessageBodyStyle Wrapped, RequestFormat=WebMessageFormat. Json, ResponseFormat=WebMessageFormat. Json)]
FileUploadResult Upload2Attachment (string filename, string count, string token, bool last, Stream, Stream).
I always suggest a 400 error, front desk call calling code below
Public string Upload (string fileName, string count, byte [] fileContent, char last='1')
{
Var the req=HttpWebRequest. Create (${_uploadAttachUrl}?" FileName={fileName} & amp; A count={count} & amp; Token={_token} & amp; As HttpWebRequest last=1 ");
The req. Method="POST";
The req. ContentType="application/json";
The req. CookieContainer=cookies;
Using (var reqStream=the req. GetRequestStream ())
{
//var postData=https://bbs.csdn.net/topics/new {fileName=fileName, count=count, token=_token, last=1, stream=fileContent};
//var bytes=UnicodeEncoding. UTF8. GetBytes (JsonConvert. SerializeObject (postData));
//reqStream. Write (0 bytes, bytes. The Length).
ReqStream. Write (fileContent, 0, fileContent. Length);
ReqStream. Flush ();
}
Using (var responseStream=the req. The method GetResponse (). The GetResponseStream ())
{
Using (var reader=new StreamReader (responseStream))
{
Return reader. ReadToEnd ();
}
}
}
Brother help some directions
CodePudding user response:
WCF interface is regardless of the post or get, that you would be wrong to call way WCF interface similar to the webservice call way, local agent, can you need a reference to a local callCodePudding user response: