エラー:
ServiceModel クライアント構成セクションで、コントラクト 'ICalculatorDuplex' を参照する既定のエンドポイント要素が見つかりませんでした。これは、アプリケーションの構成ファイルが見つからなかったか、このコントラクトに一致するエンドポイント要素がクライアント要素に見つからなかったためである可能性があります。
参照リンク: http://msdn.microsoft.com/en-us/library/ms735103.aspx
using System;
using System.ServiceModel;
namespace Microsoft.ServiceModel.Samples
{
// The service contract is defined in generatedClient.cs, generated from the service by the svcutil tool.
// Define class which implements callback interface of duplex contract
public class CallbackHandler : ICalculatorDuplexCallback
{
public void Equals(double result)
{
Console.WriteLine("Equals({0})", result);
}
public void Equation(string eqn)
{
Console.WriteLine("Equation({0})", eqn);
}
}
class Client
{
static void Main()
{
// Construct InstanceContext to handle messages on callback interface
InstanceContext instanceContext = new InstanceContext(new CallbackHandler());
// Create a client with given client endpoint configuration
CalculatorDuplexClient client = new CalculatorDuplexClient(instanceContext);
// Console.WriteLine("Press to terminate client once the output is displayed.");
// Console.WriteLine();
// Call the AddTo service operation.
double value = 100.00D;
client.AddTo(value);
// Call the SubtractFrom service operation.
value = 50.00D;
client.SubtractFrom(value);
// Call the MultiplyBy service operation.
value = 17.65D;
client.MultiplyBy(value);
// Call the DivideBy service operation.
value = 2.00D;
client.DivideBy(value);
// Complete equation
client.Clear();
Console.ReadLine();
//Closing the client gracefully closes the connection and cleans up resources
client.Close();
}
}
}
クライアント構成:
<system.serviceModel>
<client>
<endpoint address="http://196.9.200.26:8000/ServiceModelSamples/service"
binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_ICalculatorDuplex"
contract="ServiceReference1.ICalculatorDuplex" name="WSDualHttpBinding_ICalculatorDuplex">
<identity>
<servicePrincipalName value="host/ln-pun-026.imgpoint.com" />
</identity>
</endpoint>
</client>
<bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding_ICalculatorDuplex" useDefaultWebProxy="true" bypassProxyOnLocal="false" clientBaseAddress="http://196.9.200.26:8000/myClient/" >
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" />
<security mode="None"/>
</binding>
</wsDualHttpBinding>
</bindings>
</system.serviceModel>