Before:
PAS.UserAuths ret = new PAS. UserAuths();
PAS. PASservicesSoapClient svc = ne w PAS.PASservicesSoapClient();
var securityHeader = new PHSCredentialsHeader()
{
Username = _ Username,
Password = _ Password
};
using (System. ServiceModel. OperationContextScope contextScope = new System. ServiceModel. OperationContextScope(svc. InnerChannel))
{
System. ServiceModel.OperationContext. Current. OutgoingMessageHeaders.Add( securityHeader);
After using dll:
PAS.UserAuths ret = new PAS.UserAuths();
PAS.PASservicesSoapClient svc = new PAS.PASservi cesSoapClient();
PHSServiceAI.PHSServiceWrapper sw = new PHSServiceAI.PHSServiceWrapper (_Username, _Password, svc. InnerChannel);
using (sw.cScope)
{
DLL Code:
namespace PHSServiceAI
{
///
/// Security HeaderWrapper for PHS AI Servcies
///
public class PHSServiceWrapper
{
public string UserId {get; set; }
public stringPassword { get; set; }
public System.ServiceModel.OperationContextS cope cScope { get; set; }
publicPHSServiceWrapper()
{
}
publicPHSServiceWrapper(string uName, string pw, System. ServiceModel.IContextChannel ic)
{
try
{
this.UserId =uName;
this.Password= pw;
PHSCredentialsHeader crdHdr;
crdHdr = new PHSCredentialsHeader()
{
Username =this.UserId,
Password =this.Password
};
cScope = newSystem.ServiceModel.OperationC ontextScope(ic);
System.ServiceModel.OperationContext. Current. OutgoingMessageHeaders.Add( crdHdr);
}
catch (Exceptione)
{
//TODO log e.Message etc.
}
}
}
}
No comments:
Post a Comment