private echoResponse BuildResponseMessage(Structure businessResponse) { var echoReply = new echoResponse(); echoReply.structureToEcho = businessResponse; echoReply.Framework = new LibertyFrameworkHeader(); return(echoReply); }
public echoResponse Echo(echo echoRequest) { ValidateLibertyFrameworkHeader(echoRequest.Framework); Structure businessResponse = ProcessBusinessLogic(echoRequest.structureToEcho); echoResponse echoReply = BuildResponseMessage(businessResponse); InsertWsAddressingMessageIdOnResponse(); return(echoReply); }
public static string ExecuteWS(string signingCertificateNameClient, string address, SecurityToken issuedToken) { X509Certificate2 certificate2Client = CertificateUtil.GetCertificate(StoreName.My, StoreLocation.LocalMachine, signingCertificateNameClient); ChannelFactory <IEchoService> factory = null; try { factory = new ChannelFactory <IEchoService>(new ServiceproviderBinding(false), address); factory.Endpoint.Contract.ProtectionLevel = ProtectionLevel.Sign; factory.ConfigureChannelFactory(); factory.Credentials.ClientCertificate.Certificate = certificate2Client; factory.Credentials.ServiceCertificate.DefaultCertificate = CertificateUtil.GetCertificate(StoreName.My, StoreLocation.LocalMachine, "CN=STS");// SigningCertificateNameGenevaService); factory.Endpoint.Contract.ProtectionLevel = ProtectionLevel.Sign; var service = ChannelFactoryOperations.CreateChannelWithIssuedToken <IEchoService>(factory, issuedToken); Structure str = new Structure(); str.value = "Testing .NET client"; var echoRequest = new echo(); echoRequest.Framework = new LibertyFrameworkHeader(); echoRequest.structureToEcho = str; echoResponse result = null; result = service.Echo(echoRequest); return(result.structureToEcho.value); } catch (Exception e) { if (factory != null && factory.State == CommunicationState.Opened) { factory.Close(); } throw; } finally { if (factory.State == CommunicationState.Opened) { factory.Close(); } } }