Programming clients-slides

  • 451 views
Uploaded on

 

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
451
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
5
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1.      
  • 2.   
  • 3.     
  • 4.    
  • 5.    
  • 6.
  • 7.    ChannelFactory<IInvoiceService> cf = new ChannelFactory<IInvoiceService>(endpoint); ...
  • 8.  ChannelFactory<IInvoiceService> factory = new ChannelFactory<IInvoiceService>( new BasicHttpBinding(), new EndpointAddress("http://server/invoiceservice")); ... ChannelFactory<IInvoiceService> factory = new ChannelFactory<IInvoiceService>("httpEndpoint"); ...
  • 9. <configuration> <system.serviceModel> <client> <endpoint name="httpEndpoint" address="http://server/invoiceservice" binding="basicHttpBinding" contract="IInvoiceService"/> <endpoint name="tcpEndpoint" address="net.tcp://server:8081/invoiceservice" binding="netTcpBinding" contract="IInvoiceService"/> </client> </system.serviceModel> </configuration>
  • 10.    ChannelFactory<IInvoiceService> factory = new ChannelFactory<IInvoiceService>("tcpEndpoint"); IInvoiceService channel = factory.CreateChannel(); channel.SubmitInvoice(invoice); ((IClientChannel)channel).Close();
  • 11.         
  • 12.     public interface IInvoiceServiceChannel : IInvoiceService, System.ServiceModel.IClientChannel { } ChannelFactory<IInvoiceServiceChannel> factory = new ChannelFactory<IInvoiceServiceChannel>("tcpEndpoint"); IInvoiceServiceChannel channel = factory.CreateChannel(); channel.SubmitInvoice(invoice); channel.Close();
  • 13.     public partial class InvoiceServiceClient : ClientBase<IInvoiceService>, IInvoiceService { public InvoiceServiceClient() { } public InvoiceServiceClient(string endpointName) : base(endpointName) { } ... // you're service contract methods will be here
  • 14. ... InvoiceServiceClient client = new InvoiceServiceClient("httpEndpoint"); Invoice invoice = new Invoice(); invoice.CustomerName = "Acme, Inc"; invoice.Amount = 100.00; invoice.InvoiceDate = DateTime.Now; client.SubmitInvoice(invoice); client.Close(); ...
  • 15.      
  • 16. <configuration> <system.serviceModel> <client> <endpoint name="httpEndpoint" address="http://server/invoiceservice" binding="basicHttpBinding" bindingConfiguration="MyConfiguration" contract="InvoiceServiceReference.IInvoiceService" /> </client> <bindings> <basicHttpBinding> <binding name="MyConfiguration" sendTimeout="00:05:00"> <security mode="Transport"> <transport clientCredentialType="Basic"/> </security> </binding> </basicHttpBinding> </bindings> </system.serviceModel> </configuration>
  • 17. <configuration> <system.serviceModel> <client> <endpoint name="httpEndpoint" address="http://server/invoiceservice" binding="basicHttpBinding" behaviorConfiguration="viaBehavior" contract="InvoiceServiceReference.IInvoiceService" /> </client> <behaviors> <endpointBehaviors> <behavior name="viaBehavior"> <clientVia viaUri="http://router/invoiceservice"/> </behavior> </endpointBehaviors> </behaviors> ...
  • 18.
  • 19. InvoiceServiceClient client = new InvoiceServiceClient("httpEndpoint"); Invoice invoice = ... // create invoice try { client.SubmitInvoice(invoice); client.Close(); } catch (FaultException fe) { Console.WriteLine(fe); client.Abort(); } catch (CommunicationException ce) { Console.WriteLine(ce); client.Abort(); } catch (TimeoutException te) { Console.WriteLine(te); client.Abort(); } ...
  • 20.       
  • 21.     
  • 22.    
  • 23.        
  • 24.          