Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
windows phone 8.1中的C#签名Soap头_C#_Soap_Windows Phone - Fatal编程技术网

windows phone 8.1中的C#签名Soap头

windows phone 8.1中的C#签名Soap头,c#,soap,windows-phone,C#,Soap,Windows Phone,我们需要在Windows8.1手机上使用带有签名时间戳头的Soap调用服务器。我们使用VS Community 2015作为开发环境。webservice网站已向我们提供了可供签署的证书。不使用用户名/密码 我们尝试使用从wsdl文件添加服务引用生成的代码,但没有找到如何对标头进行签名。当我们尝试运行调用时,我们会收到一个“InvalidOperationException”,其中的文本表示我们需要提供用户名。如果我们随后在ClientCredentials中提供随机用户名/密码,我们会收到Me

我们需要在Windows8.1手机上使用带有签名时间戳头的Soap调用服务器。我们使用VS Community 2015作为开发环境。webservice网站已向我们提供了可供签署的证书。不使用用户名/密码

我们尝试使用从wsdl文件添加服务引用生成的代码,但没有找到如何对标头进行签名。当我们尝试运行调用时,我们会收到一个“InvalidOperationException”,其中的文本表示我们需要提供用户名。如果我们随后在ClientCredentials中提供随机用户名/密码,我们会收到MessageSecurityException,其中包含文本“从另一方接收到不安全或安全性不正确的故障。有关故障代码和详细信息,请参阅内部FaultException。”

是否有人设法使用证书在Windows 8.1 phone上对带有时间戳的soap头进行签名?请注意,MSDN上soap客户端的大多数页面都找不到页面

在此之后,我们查看了在c#中签名soap请求头的示例。在下面的代码示例中,我们没有发现System.Security.Cryptography.XML包不可用。有人知道XmlDsigC14NTransform被移动到哪里了吗?或者,为了在soap报头中获取时间戳的DigestValue,将使用什么替代方法

关于这一点的底线问题是,有没有人举过如何在Windows8.1手机上使用带时间戳的soap头执行soap请求的例子

以下是我们已经尝试过的。姓名、地址等发生变化

        SoapWS.myRequest req = new SoapWS.myRequest();
        // setup the request fields


        CustomBinding binding = new CustomBinding();
        binding.Namespace = "urn:<the name space>";
        binding.Name = "<name of binding>";
        TransportSecurityBindingElement securityElement = new TransportSecurityBindingElement();
        securityElement.IncludeTimestamp = true;


        X509Certificate cert = new X509Certificate(<from loaded bytes>);

        binding.Elements.Add(new TextMessageEncodingBindingElement(MessageVersion.Soap11, System.Text.Encoding.UTF8));
        binding.Elements.Add(securityElement);
        binding.Elements.Add(new HttpsTransportBindingElement());

        SoapWS.myRequestClient client = new SoapWS.myRequestClient(
            binding,
            addr);

        //client.ClientCredentials.UserName.UserName = "admin";
        //client.ClientCredentials.UserName.Password = "admin";

        using (new OperationContextScope(client.InnerChannel))
        {
            // Add a SOAP Header to an outgoing request
            MessageHeader aMessageHeader = MessageHeader.CreateHeader("Security", binding.Namespace, cert);
            OperationContext.Current.OutgoingMessageHeaders.Add(aMessageHeader);
        }

        client.myRequestCompleted += Client_completed;
        client.myRequestSessionAsync(req);
SoapWS.myRequest req=new SoapWS.myRequest();
//设置请求字段
CustomBinding=新的CustomBinding();
binding.Namespace=“urn:”;
绑定。名称=”;
TransportSecurityBindingElement securityElement=新的TransportSecurityBindingElement();
securityElement.IncludeTimestamp=true;
X509Certificate cert=新的X509Certificate();
添加(新的TextMessageEncodingBindingElement(MessageVersion.Soap11,System.Text.Encoding.UTF8));
binding.Elements.Add(securityElement);
添加(新的HttpsTransportBindingElement());
SoapWS.myRequestClient=新的SoapWS.myRequestClient(
结合
地址);
//client.ClientCredentials.UserName.UserName=“admin”;
//client.ClientCredentials.UserName.Password=“admin”;
使用(新OperationContextScope(client.InnerChannel))
{
//将SOAP头添加到传出请求
MessageHeader-aMessageHeader=MessageHeader.CreateHeader(“安全性”,binding.Namespace,cert);
OperationContext.Current.OutgoingMessageHeaders.Add(aMessageHeader);
}
client.myRequestCompleted+=客户端_已完成;
client.myRequestSessionAsync(req);

以下答案可能会有所帮助:感谢您,该答案有助于加载x509证书,但仍无法在windows phone 8.1上对时间戳进行重新校准和签名,仍在搜索LIB以尝试执行此操作。