Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/338.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
Java 使用WCF使用SOAP服务-需要加密标头_Java_C#_Web Services_Wcf_Soap - Fatal编程技术网

Java 使用WCF使用SOAP服务-需要加密标头

Java 使用WCF使用SOAP服务-需要加密标头,java,c#,web-services,wcf,soap,Java,C#,Web Services,Wcf,Soap,我正在编写一个.NET4.5MVC应用程序,并添加了一个服务引用。我正在尝试使用Java web服务,其中请求需要如下所示: <soap:Header> <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasi

我正在编写一个.NET4.5MVC应用程序,并添加了一个服务引用。我正在尝试使用Java web服务,其中请求需要如下所示:

<soap:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
     <xenc:EncryptedKey Id="EK-DC1CFFE24489AA1D8D1384341997399115" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">
        <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5"/>
        <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
           <wsse:SecurityTokenReference>
              <ds:X509Data>
                 <ds:X509IssuerSerial>
                    <ds:X509IssuerName />
                    <ds:X509SerialNumber />
                 </ds:X509IssuerSerial>
              </ds:X509Data>
           </wsse:SecurityTokenReference>
        </ds:KeyInfo>
        <xenc:CipherData>
           <xenc:CipherValue />
        </xenc:CipherData>
        <xenc:ReferenceList>
           <xenc:DataReference URI="#ED-345"/>
        </xenc:ReferenceList>
     </xenc:EncryptedKey>
     <wsu:Timestamp wsu:Id="TS-344">
        <wsu:Created>2013-11-13T11:26:37.398Z</wsu:Created>
        <wsu:Expires>2014-11-13T11:31:37.398Z</wsu:Expires>
     </wsu:Timestamp>
     <wsse:UsernameToken wsu:Id="UsernameToken-343">
        <wsse:Username />
        <xenc:EncryptedData Id="ED-345" Type="http://www.w3.org/2001/04/xmlenc#Element" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">
           <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"/>
           <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
              <wsse:SecurityTokenReference wsse11:TokenType="http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#EncryptedKey" xmlns:wsse11="http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd">
                 <wsse:Reference URI="#EK-DC1CFFE24489AA1D8D1384341997399115"/>
              </wsse:SecurityTokenReference>
           </ds:KeyInfo>
           <xenc:CipherData>
              <xenc:CipherValue />
           </xenc:CipherData>
        </xenc:EncryptedData>
     </wsse:UsernameToken>
  </wsse:Security>
此服务还使用X.509证书来保证HTTPS上的传输安全。我能够让它连接到服务,并在usernametoken元素中以纯文本形式发送用户名和密码。是否有方法调整端点配置以加密请求中的密码

我当前的配置:

<system.serviceModel>
<behaviors>
      <endpointBehaviors>
        <behavior name="endpointCredentialBehavior">
          <clientCredentials>
            <clientCertificate findValue="XXX.COM"
                               storeLocation="LocalMachine"
                               storeName="Root"
                               x509FindType="FindBySubjectName" />
          </clientCredentials>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <bindings>
      <wsHttpBinding>
        <binding name="Binding1">
          <security mode="TransportWithMessageCredential">
            <transport clientCredentialType="Certificate"/>
            <message clientCredentialType="UserName" negotiateServiceCredential="true"
                  establishSecurityContext="true"
                  algorithmSuite="Basic128Rsa15" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="https://secure.com/java/service"
        binding="wsHttpBinding" bindingConfiguration="Binding1" behaviorConfiguration="endpointCredentialBehavior"
        contract="NS.WCF.PPPortType" name="PPPort" />
    </client>
  </system.serviceModel>  

没有办法用香草WCF,对不起。也许这项服务可以让你加密整个用户名头。呃,我想你是对的。我能够用WCF加密SOAP消息的整个正文和标题,但是为了让它根据这些规范生成标题,我必须创建一个.NET 2.0 Web引用,同时混合一些WSE 3.0来完成细节。