C# 使用C使用wsse java spring安全web服务

C# 使用C使用wsse java spring安全web服务,c#,spring,soap,header,wsse,C#,Spring,Soap,Header,Wsse,总之,我正在尝试使用C使用javaspring wsse web服务。这就是我需要发送的web服务头的样子 <soapenv:Header> <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <wsse:UsernameToken wsu:I

总之,我正在尝试使用C使用javaspring wsse web服务。这就是我需要发送的web服务头的样子

<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1"
 xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-27777511"
 xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>username</wsse:Username>
<wsse:Password
 type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">
 password</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
我从这里得到了定制绑定示例。端点是http,我无法发送时间戳,因此使用它

我得到一个错误:

“定制绑定”。对客户具有约束力 “ws”。合同是 配置了需要传输级别的身份验证模式 正直和保密。然而,运输无法提供 正直和保密

不管怎样,如果我直截了当的话,我很抱歉。这是我第一次尝试使用任何JavaSpringWebService。如果需要,我可以提供更多信息。我更喜欢在我的.cs文件中以编程方式进行。非常感谢您的任何想法/帮助

  <?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="wsSoap11" closeTimeout="00:01:00" openTimeout="00:01:00"
                    receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
                    bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <security mode="None">
                        <transport clientCredentialType="None" proxyCredentialType="None"
                            realm="" />
                        <message clientCredentialType="UserName" algorithmSuite="Default" />
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>
    </system.serviceModel>
</configuration>
            SecurityBindingElement securityElement = SecurityBindingElement.CreateUserNameOverTransportBindingElement();
            securityElement.IncludeTimestamp = false;
            TextMessageEncodingBindingElement encodingElement = new TextMessageEncodingBindingElement(MessageVersion.Soap11, Encoding.UTF8);
            HttpTransportBindingElement transportElement = new HttpTransportBindingElement();

            CustomBinding customBinding = new CustomBinding(securityElement, encodingElement, transportElement);

            EndpointAddress endpoint = new EndpointAddress("http://11.11.22.222:8080/OpenClinica-ws/ws/studyEventDefinition/v1/studyEventDefinitionWsdl.wsdl");

            ServiceReference1.wsClient cl = new  wsClient(customBinding, endpoint);

            cl.ClientCredentials.UserName.UserName = "x";
            cl.ClientCredentials.UserName.Password = "y";

            studyRefType sr = new studyRefType();
            sr.identifier = "S_12345";

            listAllRequest la = new listAllRequest();
            la.studyEventDefinitionListAll = new studyEventDefinitionListAllType();
            la.studyEventDefinitionListAll.studyRef = sr;
            var response = cl.listAll(la);