[英]WCF REST Service returns Error :The remote server returned an error: (400) Bad Request
I have call Rest WCF Service from a project like below 我已经从以下项目中致电Rest WCF Service
userAlias = "test";
var url = new StringBuilder();
url.Append(
string.Format("https://webdemo-t.orioninc.com:8443/Services/2012v2/TestService.svc/AddAttachment?User={0}&Engagement={1}&FileName={2}&DocumentTrasferID={3}&fileSize={4}&ActivityName={5}",userAlias, engagementName, fileName, documentTranferId, fileSize, activityName));
WebRequest request = WebRequest.Create(url.ToString());
CurrentUrl = url.ToString();
var networkCredential = new NetworkCredential("jame", "test", "company");
request.Credentials = networkCredential;
WebResponse response = request.GetResponse();
Encoding encoding = Encoding.GetEncoding(1252);
var responseStream = new StreamReader(response.GetResponseStream());
string responseResult = responseStream.ReadToEnd();
responseStream.Close();
Console.WriteLine(responseResult);
while calling these service i got exception The remote server returned an error: (400) Bad Request. 调用这些服务时,我得到了异常远程服务器返回错误:(400)错误的请求。 When i try to return a normal string in the WCH implementation method i got the webresponse result correctly.How can i resolve this error? 当我尝试在WCH实现方法中返回普通字符串时,我正确地获得了webresponse结果。如何解决此错误?
WCF Implementation Method WCF实施方法
public string AddAttachment(string User, string Engagement, string FileName, string DocumentTrasferID, string fileSize, string ActivityName)
{
dynamic _Trackerfaccade = new KPMG.EauditEmailService.Facade.EAppEmail();
string Result = _Trackerfaccade.AddAttachment(User, Engagement, FileName, DocumentTrasferID, fileSize, FileName);
return Result;
}
Operation Contract 经营合同
[OperationContract]
[WebGet(UriTemplate = "/AddAttachment?User={userAlias}&Engagement={engagementName}&FileName={FileName}&DocumentTrasferID={documentTranferId}&fileSize={fileSize}&activityName={activityName}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
string AddAttachment(string userAlias, string engagementName, string documentTranferId,string fileName,string fileSize,string activityName);
"/AddAttachment?User={0}&Engagement={1}&FileName={2}&DocumentTrasferID={3}&fileSize={4}&ActivityName={5}"
"/AddAttachment?userAlias={userAlias}&engagementName={engagementName}&documentTranferId={documentTranferId}&fileName={fileExtension}&fileSize={fileSize}&activityName={activityName}"
url pattern and real url are not same, your request can't found this method 网址格式和实际网址不相同,您的请求找不到此方法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.