简体   繁体   English

找不到WS-Security标头

[英]No WS-Security header found

I am trying to consume a service which demo url is as follow 我正在尝试使用一个服务,其中演示网址如下

[https://demo.unicommerce.com/services/soap/uniware13.wsdl?facility=01][1] [https://demo.unicommerce.com/services/soap/uniware13.wsdl?facility=01][1]

when i add this service and try to use this in my code as follow 当我添加此服务并尝试在我的代码中使用此服务,如下所示

using abc;
public partial class unicommerce : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        unicommerce u = new unicommerce();

        UnicommerceClient us = new UnicommerceClient();


        Customer c=new Customer ();
        PartyAddress pa=new PartyAddress ();
        pa.StateCode="25";
        pa.Pincode="302017";
        c.BillingAddress=pa;
        PartyContact p=new PartyContact ();

        c.Contact=p;
        c.CSTNumber="123";
        c.CustomerCode="ABC";
        c.Name="example";
        c.PAN="CYKPS7842";
        c.Website="http://mywebsite.in";

        CreateCustomerRequest cr = new CreateCustomerRequest();
        cr.Customer = c;
        us.CreateCustomer(cr);

    }
}

Its throwing error 它的投掷错误

No WS-Security header found

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.ServiceModel.FaultException: No WS-Security header found
  [1]: https://demo.unicommerce.com/services/soap/uniware13.wsdl?facility=01

I asked to the person who made this service regarding this , he said to me that this service is created on apace with java code. 我问过这个服务的人,他告诉我这个服务是用java代码快速创建的。

As far i have idea this error is related to user name and password (authentication) , but not getting where should i pass those credentials . 到目前为止我知道这个错误与用户名和密码(身份验证)有关,但没有得到我应该通过这些凭据的位置。

U can use the standard .Net WSS Implementation from Microsoft.Web.Services2 您可以使用Microsoft.Web.Services2中的标准.Net WSS实现

using Microsoft.Web.Services2.Security.Tokens;
using Microsoft.Web.Services2.Security.Utility;

UsernameToken token = new UsernameToken(username, password, passwordOption.SendHashed);          

Microsoft.Web.Services2.Security.Utility.Timestamp ts = new Timestamp();

XmlDocument doc = new XmlDocument();

XmlElement token = token.GetXml(doc);
XmlElement timestamp = ts.GetXml(doc);

string stoken = token.InnerXml;
string stimestamp = ts.InnerXml;

and so on, works perfect. 等等,工作完美。

Microsoft.Web.Services2.dll can be found here: 可以在此处找到Microsoft.Web.Services2.dll:

http://www.microsoft.com/downloads/details.aspx?FamilyId=FC5F06C5-821F-41D3-A4FE-6C7B56423841&displaylang=en http://www.microsoft.com/downloads/details.aspx?FamilyId=FC5F06C5-821F-41D3-A4FE-6C7B56423841&displaylang=en

您必须知道与Web服务通信的安全要求,然后将安全标头添加到您的代码中,请在此处查看示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM