2013-06-18 15 views
5

Sto cercando di utilizzare un servizio che demo url è come seguireNo WS-Security ha trovato

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

quando aggiungo questo servizio e cercare di utilizzare questo nel mio codice come seguire

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); 

    } 
} 

il suo errore di lancio

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 

Ho chiesto alla persona che ha effettuato questo servizio per quanto riguarda questo, mi ha detto che questo servizio è stato creato in fretta con il codice java.

Finora ho idea che questo errore è legato al nome utente e password (autenticazione), ma non ottenere dove devo passare quelle credenziali.

+0

ottenendo lo stesso errore durante il tentativo di fare integrazione Unicommerce. Hai capito il problema ???? –

+1

è possibile passare le credenziali a us.ClientCredentials.UserName.username = "username"; us.ClientCredentials.UserName.Password = "password"; –

risposta

1

è necessario conoscere il requisito di sicurezza per comunicare con il servizio web, e quindi aggiungere le intestazioni di sicurezza per il vostro controllo del codice un esempio here

+0

ho già controllato quell'esempio ma non capisco come usare quel codice nel mio codice? – rahularyansharma

+0

Non è necessario utilizzare questo codice esattamente, per prima cosa controllare qual è il requisito di sicurezza per il servizio con cui si ha a che fare, quindi aggiungere l'intestazione di sicurezza corretta. nel caso in cui tu abbia un token nome utente semplice nel servizio, puoi utilizzare questo esempio. Devi usare UsernameToken, ottenere SoapContext dal tuo proxy di servizio, quindi impostare il Timestamp e aggiungere il token username ad esso come nell'esempio –

2

U può utilizzare l'implementazione standard .Net WSS da Microsoft.Web. Servizi2

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; 

e così via, funziona perfettamente.

Microsoft.Web.Services2.dll può essere trovato qui:

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

+0

token XmlElement = token.GetXml (doc); cosa è doc qui? – rahularyansharma

+0

XmlDocument doc = new XmlDocument(); –

+0

Ho anche aggiunto come ottenere il valore stringa –

Problemi correlati