Before:
PAS.UserAuths ret = new PAS.UserAuths();
PAS.PASservicesSoapClient svc = new 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.PASservicesSoapClient ();
PHSServiceAI.PHSServiceWrapper sw = newPHSServiceAI. 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. OperationContextScope cScope { get; set; }
publicPHSServiceWrapper()
{
}
publicPHSServiceWrapper( stringuName, string pw, System.ServiceModel. IContextChannelic)
{
try
{
this.UserId =uName;
this.Password= pw;
PHSCredentialsHeader crdHdr;
crdHdr = new PHSCredentialsHeader ()
{
Username =this.UserId,
Password =this.Password
};
cScope = newSystem.ServiceModel. OperationContextScope (ic);
System.ServiceModel. OperationContext.Current. OutgoingMessageHeaders.Add( crdHdr);
}
catch (Exceptione)
{
//TODO log e.Message etc.
}
}
}
}