只有绝对 URI 才能用作基址。using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Derivativescaluclator;
using IDerivativescaluclator;
using System.ServiceModel;
using System.Configuration;namespace Host
{
public class Program
{
public static void Main(string[] args)
{
Type serviceType = typeof(DerivativesCalculatorServiceType);
using (ServiceHost host = new ServiceHost(serviceType))
{
host.Open();
Console.WriteLine("The derivatives calculator service is available.");
Console.ReadKey(true);
host.Close(); }
}
}
}<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel> <services>
<service name="Derivativescaluclator.DerivativesCalculatorServiceType">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000//Derivatives/"/>
<add baseAddress="net.tcp//localhost:8010/Derivatives/"/>
</baseAddresses>
</host>
<endpoint address="Calculator"
binding="basicHttpBinding"
contract="IDerivativescaluclator.Icalculator">
</endpoint>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="bindingSettings" messageEncoding="Mtom"></binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
</configuration>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IDerivativescaluclator;
namespace Derivativescaluclator
{
public class DerivativesCalculatorServiceType : Icalculator
{
decimal Icalculator.CalculateDerivative(
string[] sumbols,
decimal[] parameters,
string[] functions
)
{
//throw new Exception("The method Or opeation is not implemented.");
return new calculator().CalculateDerivative(sumbols, parameters, functions);
}
void Icalculator.DoNothing()
{
// throw new Exception("The method Or opeation is not implemented.");
return;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;namespace IDerivativescaluclator
{
[ServiceContract]
public interface Icalculator
{
decimal CalculateDerivative(
string[] sumbols,
decimal[] parameters,
string[] functions
);
void DoNothing();
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Derivativescaluclator;
using IDerivativescaluclator;
using System.ServiceModel;
using System.Configuration;namespace Host
{
public class Program
{
public static void Main(string[] args)
{
Type serviceType = typeof(DerivativesCalculatorServiceType);
using (ServiceHost host = new ServiceHost(serviceType))
{
host.Open();
Console.WriteLine("The derivatives calculator service is available.");
Console.ReadKey(true);
host.Close(); }
}
}
}<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel> <services>
<service name="Derivativescaluclator.DerivativesCalculatorServiceType">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000//Derivatives/"/>
<add baseAddress="net.tcp//localhost:8010/Derivatives/"/>
</baseAddresses>
</host>
<endpoint address="Calculator"
binding="basicHttpBinding"
contract="IDerivativescaluclator.Icalculator">
</endpoint>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="bindingSettings" messageEncoding="Mtom"></binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
</configuration>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IDerivativescaluclator;
namespace Derivativescaluclator
{
public class DerivativesCalculatorServiceType : Icalculator
{
decimal Icalculator.CalculateDerivative(
string[] sumbols,
decimal[] parameters,
string[] functions
)
{
//throw new Exception("The method Or opeation is not implemented.");
return new calculator().CalculateDerivative(sumbols, parameters, functions);
}
void Icalculator.DoNothing()
{
// throw new Exception("The method Or opeation is not implemented.");
return;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;namespace IDerivativescaluclator
{
[ServiceContract]
public interface Icalculator
{
decimal CalculateDerivative(
string[] sumbols,
decimal[] parameters,
string[] functions
);
void DoNothing();
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货