English 中文(简体)
遥远的服务器还留下了一个错误:(400) 垃圾邮件,同时耗用一个WCF服务机。
原标题:The remote server returned an error: (400) Bad Request while consuming a WCF Service
  • 时间:2011-10-17 22:14:38
  •  标签:
  • asp.net
  • wcf

参看下文所述守则。 de虽然送达请求书。 GetResponse()说,错误已被推翻。

Uri uri = new Uri(address);
string data = "<s:Envelope xmlns:s= http://schemas.xmlsoap.org/soap/envelope/ ><s:Body><HasRole xmlns= http://tempuri.org/ ><userName>" + sid + "</userName><role>" + role + "</role></HasRole></s:Body></s:Envelope>";

data.Replace(" ", """);

// Create a byte array of the data we want to send  
byte[] byteData = UTF8Encoding.UTF8.GetBytes(data);

if (uri.Scheme == Uri.UriSchemeHttps)
{
    HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);
    request.Method = "POST";// WebRequestMethods.Http.Post;
    request.ContentLength = byteData.Length;
    request.ContentType = "application/soap+xml; charset=UTF-8"; // "text/xml; charset=utf-8";
    //request.ContentType = "application/x-www-form-urlencoded";

    //Stream requestStream = request.GetRequestStream();
    using (Stream writer = request.GetRequestStream())
    {
        writer.Write(byteData, 0, byteData.Length);
    }
    //writer.Close();

    using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
    {
        // Get the response stream  
        StreamReader reader = new StreamReader(response.GetResponseStream());
        string tmp = reader.ReadToEnd();
        Response.Close();
        Response.Write(tmp);
    }
问题回答

我将翻一番检查《欧洲刑法》。 如果URL在客户方面看ok,我建议查看服务器上的出入记录,以了解URL受到的打击。 4xx错误指未找到资源。 如果最终点是正确的,但请求是空洞的,那么你就会有5xx个错误代码。 (假设你的服务器辅助框架使用标准的《吉大港山区应急守则》。)

正如有人提到的那样,你应当利用“附加服务”来从“网络”客户中获取“世界合作框架”服务。 然而,如果你重新效仿,试图与非联系。 NET客户,你包裹缺乏头盔信息。

<s:Header>
   <Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">
specify your action namespace here (e.g. http://tempuri.org/ISomeService/Execute)
   </Action>
</s:Header>




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签