English 中文(简体)
WCF 习俗 包装和材料运输
原标题:WCF Custom JSONP Binding and httpsTransport
  • 时间:2009-09-17 17:39:03
  •  标签:

我的问题围绕着一个与JSONP相对应的IISWCF REST服务。 我在这一解决办法中使用了以下几类:。 并将其添加到地雷中。 事情在我的开发商工作站使用“运输网”的冒名,但当我试图进入发展服务器时,我遇到了一些安全问题。 这些问题通过以下配置和一个应用集合特性用户解决。 由于我没有机会让尼共(毛主义)成为尼泊尔共产党,我也把国际空间法学会的元数据库编成仅认证(我们正在使用国际空间法学会6,但很快将使用国际空间法研究所7,需要同时工作)。 我认为,目前的组合解决了我的安全问题,但在这个过程中,我的个人代表小组的回复被降级为Pregualar JSON/strong,这就是问题。 这里是相关组合:

    <services>
        <service name="IS.Core.Infrastructure.RESTRouter.Transactions" behaviorConfiguration="">
            <endpoint address="" behaviorConfiguration="webHttp" binding="customBinding"
              bindingConfiguration="jsonpBinding" contract="IS.Core.Infrastructure.RESTRouter.ITransactions">
            </endpoint>
        </service>

        <service name="IS.Core.Infrastructure.RESTRouter.Queue" behaviorConfiguration="">
            <endpoint address="" behaviorConfiguration="webHttp"  binding="customBinding"
                bindingConfiguration="jsonpBinding" contract="IS.Core.Infrastructure.RESTRouter.IQueue" />
        </service>
    </services>

    <behaviors>
        <endpointBehaviors>
            <behavior name="webHttp">
                <webHttp />
            </behavior>
        </endpointBehaviors>
    </behaviors>

    <bindings>
        <customBinding>
            <binding name="jsonpBinding">
                <jsonpMessageEncoding />
                <httpsTransport
                      manualAddressing="true"
                      authenticationScheme="Ntlm" />
            </binding>
        </customBinding>
    </bindings>

    <extensions>
        <bindingElementExtensions>
            <add name="jsonpMessageEncoding"
              type="IS.Core.Infrastructure.RESTRouter.JsonpBindingExtension, RESTRouter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
        </bindingElementExtensions>
    </extensions>

这里是接口方法定义之一:

    [OperationContract]
    [WebGet(UriTemplate = "{ModelPath}/{ObjectTypeName}?callback={callback}", ResponseFormat = WebMessageFormat.Json)]
    [JSONPBehavior(callback = "callback")]
    JSONPXml NewObject(string ModelPath, string ObjectTypeName, string callback);

执行:

    [OperationBehavior(Impersonation = ImpersonationOption.Allowed)]
    public JSONPXml NewObject(string ModelPath, string ObjectTypeName, string callback) {

        int val = getEmployeeIdByNTUsername(OperationContext.Current.ServiceSecurityContext.PrimaryIdentity.Name);

        JSONPXml jsp = null;
        EntityPluginReflectorClient client = null;
        try {
            client = new EntityPluginReflectorClient();
            string output = client.NewObject(ModelPath, ObjectTypeName);
            jsp = new JSONPXml() { xml = output };
        } catch (Exception e) {
            InfrastructureLog.WriteException(this, "NewObject", e);
            jsp = getExceptionResponse(e);
        }
        finally {
            client.Close();
        }
        return (jsp);
    }

这里是数据合同:

[DataContract()]
public class JSONPXml {
    public JSONPXml() { }
    [DataMember]
    public string xml;
}

让我知道,是否需要更多信息,并对此加以研究。

问题回答

我不是回答的100%,但这里是帮助你缩小答案的几个方面:

对于开端人来说,如果你将“保护水平明确贴在签字人或EncodeAndSign上,那么你必须使用一种有安全保障的约束力,或者将提出例外。 如果你试图通过http://www.un.org/www.un.org/Depts/dpa/index.htm查阅,这将开始放弃例外情况。

第二,因为你使用习俗 具有约束力的是,你需要告诉它你在约束中想要什么样的安全。 我不认为它足以具体指明<代码>httpstransport。 你们通过security tag 。 您的音响需要制定authenticationMode=“SspiNegotiated”

http://msdn.microsoft.com/en-us/library/ms731377.aspx”rel=“nofollow noreferer” 约束性习俗:

The order in which elements appear in the stack matters, because it is the order in which operations are applied to the message. The recommended order of stack elements is the following:

交易(选项)

可靠信息(备选方案)

安全(选择)

运输

Encoder(选择)

More info on Custom Binding Security here and here Hopefully that helps.

这似乎似乎是一个明显的例子,但你已经核实,在你的发展服务器中,你仍在通过“召回”的问答。

看看JSONPEncoder的消息来源,即使尚未收到“召回”参数,它似乎仍将写给答复的JSON信息。 这种做法将不采用 Java本包。





相关问题