English 中文(简体)
WCF to WCF communication 401, HttpClient
原标题:WCF to WCF communication 401, HttpClient
  • 时间:2012-04-13 12:57:13
  •  标签:
  • wcf
  • iis
问题回答

我认为,这与你设立网络服务有关。 最好由你创建GET、POST、Put、DELETE心beat,要求提供新的服务,然后从fiddler那里检查这些服务。 如果你获得401份,这或许意味着你无法获得某种身份。

采取步骤确定:

  1. Give user read/write/modify/execute/..similar rights at your WCF publish folder
  2. Create app pool for this site in .net 4 integrated
  3. Set this user to application pool identity, enable anonymous mode
  4. Enable PUt,Delete verbs as well

a. 用于测试电话的心脏部分:

  [DataContract]
public class StatusInfo
{
    [DataMember]
    public string MachineName { get; set; }

    [DataMember]
    public string IpAddress{ get; set; }

    [DataMember]
    public string Methodname { get; set; }

    public override string ToString()
    {
        return "Machinename:" + MachineName + " ;IP:" + IpAddress + "; Method:" + Methodname;
    }
}

private void ResolveStatus(StatusInfo statusInfo,string methodname)
    {
        try
        {
            var context = System.ServiceModel.OperationContext.Current;

            RemoteEndpointMessageProperty property =
                (RemoteEndpointMessageProperty)
                context.IncomingMessageProperties[RemoteEndpointMessageProperty.Name];


            statusInfo.IpAddress = property.Address;
            statusInfo.MachineName = Environment.MachineName;
            statusInfo.Methodname = methodname;

        }catch(Exception ex)
        {

        }
    }
/// <summary>
    /// create task
    /// </summary>
    /// <param name="taskwrapped"></param>
    [WebInvoke(Method = "POST", UriTemplate = "", RequestFormat = WebMessageFormat.Json,
        ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
    public StatusInfo postcall()
    {
        StatusInfo statusInfo = new StatusInfo();
        logger.Trace(Tagname + "postcall");
        ResolveStatus(statusInfo, "POST");
        return statusInfo;

    }


    /// <summary>
    /// edit task
    /// </summary>
    [WebInvoke(Method = "PUT", UriTemplate = "", RequestFormat = WebMessageFormat.Json,
              ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
    public StatusInfo Edit()
    {
        StatusInfo statusInfo = new StatusInfo();
        logger.Trace(Tagname + "Edit");
        ResolveStatus(statusInfo, "PUT");
        return statusInfo;

    }

    //delete request with taskid
    [WebInvoke(Method = "DELETE", UriTemplate = "", RequestFormat = WebMessageFormat.Json,
     ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
    public StatusInfo DeleteCall()
    {
        StatusInfo statusInfo = new StatusInfo();
        logger.Trace(Tagname + "Edit");
        ResolveStatus(statusInfo, "DELETE");
        return statusInfo;

    }


    //delete request with taskid
    [WebInvoke(Method = "DELETE", UriTemplate = "/{recordid}", RequestFormat = WebMessageFormat.Json,
     ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
    public StatusInfo DeleteCallWithParam(string recordid)

    {
        StatusInfo statusInfo = new StatusInfo();
        logger.Trace(Tagname + "Edit");
        ResolveStatus(statusInfo, "DELETE/"+recordid);
        return statusInfo;

    }



enter code here

我的猜测是,你没有提交人的头脑或全权证书。

具体如下:





相关问题
Session Management with Windows Authentication

In an ASP.NET web app, using Integrated Windows Authentication, is the session tied to the windows identity? In other words, if I login (using IWA) to the app, and the app stores some "stuff" in my ...

Using Elmah with Cassini

Does anyone know if I can use Elmah with Visual Studio build-in web server(aka Cassini)? I get it working easily on IIS, but using same configuration, it doesn t work with Cassini. When I requested ...

Setting hostname in IIS, include www?

I want to set the hostname for a website I m adding in IIS 7, however do I include the www in the hostname or not? because I want both www.mysite.com and mysite.com both to point to mysite on the ...

inetpub versus any other folder

I ve run websites out of inetpub, as well as from folders just residing on the C: drive. I wonder, are there any definitive advantages to running websites out of inetputwwwroot?

IIS 6.0 hangs when serving a web-service

I am having issues with one of our web-services. It works fine on my development machine (win XP) whether I host it as a separate application or using cassini from Visual studio. Once I deploy on the ...

热门标签