客户端上的ASP.Net Web服务“肥皂头安全性未被理解”

时间:2014-10-04 10:07:08

标签: c# asp.net web-services soap wsdl

我使用供应商提供的wsdl在Visual Studio 2010中创建了一个Web服务。我已经使用他们的wsdl创建了一个接口,并为我们的实现实现了该接口。他们还需要一个SSL证书,所以我们为他们提供了证书开放的Windows ssl。 Web服务还使用soap标头实现身份验证。

但他们无法连接并收到以下错误

<soap:Body> 
  <soap:Fault> 
    <faultcode>soap:MustUnderstand</faultcode> 
    <faultstring>SOAP header Security was not understood.</faultstring> 
  </soap:Fault> 
 </soap:Body> 

我的网站服务代码如下供您参考

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;
using System.Data.SqlClient;
using System.Web.Services.Protocols;
using System.IO;
using Microsoft.Web.Services3;


namespace MyWebService1
{

    /// <summary>
    /// Summary description for PSWebService
    /// </summary>
    /// 

    [WebService(Namespace = "http://tempuri.org")]
    [WebServiceBinding(Name = "PSWebService", ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    [SoapDocumentService(RoutingStyle = SoapServiceRoutingStyle.RequestElement)]

    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the  following line. 
    // [System.Web.Script.Services.ScriptService]

    public class PSWebService : Microsoft.Web.Services3.WebServicesClientProtocol, IPartStoreRequiredServiceSOAP11Binding
    {
    public UserCredentials consumer;
    Functions objFunctions = new Functions ();
    String SqlConnStr = "Data Source=test\\test;uid=sa;pwd=abc123;database=testdb";

    public AeslPSWebService()
    {

    }

    [WebMethod]
    [SoapDocumentMethod(Binding = "PSWebService")]
    [SoapHeader("consumer", Direction = SoapHeaderDirection.In, Required = true)]
    public CustomerInformationOutput getCustomerInformation(CustomerInformationInput   custLookUpInput)
    {

        CustomerInformationOutput cio = new CustomerInformationOutput();

        try
        {
        if (checkUser())
        {
            // My business logic goes here
        }

        }
        catch (Exception ex)
        {

        }

    }



    private bool checkUser()
    {
        // In this method you can check the username and password 
        // with your database or something
        // You could also encrypt the password for more security
        if (consumer != null)
        {
        if (consumer.Username == "sa" && consumer.Password == "abc123")
            return true;
        else
            return false;
        }
        else
        return false;

    }




    }


    # region "SOAP Headers"

    public class UserCredentials : System.Web.Services.Protocols.SoapHeader
    {
    public string Username;
    public string Password;
    }

    # endregion

}

请帮忙,因为我无法解决。

0 个答案:

没有答案