SORU
8 EYLÜL 2011, PERŞEMBE


Örnek, en az XML adlı boru

XML minimal örnek Boruları (iki minimal uygulamaları, sunucu ve adlandırılmış kanal üzerinden iletişim kurabileceği müşteri, bekliyorum.) Adında birini arıyorum

Microsoft parlak yazı vardırGetting Started Tutorialbu HTTP üzerinden XML açıklar, ve bir XML hakkında benzer ve borular adında birini arıyorum.

İnternette çeşitli mesajlar buldum, ama biraz"". gelişmiş Bir şey az, zorunlu işlevi, yalnızca ihtiyacım var, benim kod eklemek ve uygulamayı çalıştırabilirim.

Nasıl adlı bir boru kullanmak yerine?

<endpoint address="http://localhost:8000/ServiceModelSamples/Service/CalculatorService"
    binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ICalculator"
    contract="ICalculator" name="WSHttpBinding_ICalculator">
    <identity>
        <userPrincipalName value="OlegPc\Oleg" />
    </identity>
</endpoint>

Nasıl adlı bir boru kullanmak yerine?

// Step 1 of the address configuration procedure: Create a URI to serve as the base address.
Uri baseAddress = new Uri("http://localhost:8000/ServiceModelSamples/Service");

// Step 2 of the hosting procedure: Create ServiceHost
ServiceHost selfHost = new ServiceHost(typeof(CalculatorService), baseAddress);

try
{
    // Step 3 of the hosting procedure: Add a service endpoint.
    selfHost.AddServiceEndpoint(
        typeof(ICalculator),
        new WSHttpBinding(),
        "CalculatorService");

    // Step 4 of the hosting procedure: Enable metadata exchange.
    ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
    smb.HttpGetEnabled = true;
    selfHost.Description.Behaviors.Add(smb);

    // Step 5 of the hosting procedure: Start (and then stop) the service.
    selfHost.Open();
    Console.WriteLine("The service is ready.");
    Console.WriteLine("Press <ENTER> to terminate service.");
    Console.WriteLine();
    Console.ReadLine();

    // Close the ServiceHostBase to shutdown the service.
    selfHost.Close();
}
catch (CommunicationException ce)
{
    Console.WriteLine("An exception occurred: {0}", ce.Message);
    selfHost.Abort();
}

Nasıl adlı bir boru kullanmak için bir istemci oluşturmak mı?

CEVAP
20 EKİM 2011, PERŞEMBE


Ben sadece this excellent little tutorial bulundu.link kırık(Cached version)

Ben de güzel, ama ben sadece borular gerekli Microsoft'un öğretici izledi.

Gördüğünüz gibi, yapılandırma dosyaları ve tüm o pis şeyleri bilmene gerek yok.

Bu arada, hem HTTP ve boruları kullanıyor. Sadece tüm kod satırları HTTP ilişkin kaldırın ve saf bir boru örnek alacaksın.

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • ABC News (Australia)

    ABC News (Au

    9 HAZİRAN 2008
  • HBO

    HBO

    17 Mayıs 2006
  • Theodore Leaf

    Theodore Lea

    29 AĞUSTOS 2006