I have created a wcf
service, but when I run , then it show error like this.
I have change the name class and interface name using rename tool.
Here is code for service.cs class
public class MyTest : MyServices
{
public string MyTask1(string a)
{
return "Hello " + a;
}
public string MyTask2(DataContract1 dc)
{
return "Hello " + dc.fname;
}
}
Here is the code for my interface :
[ServiceContract]
public interface MyServices
{
[OperationContract]
string MyTask1(string myValue);
[OperationContract]
string MyTask2(DataContract1 dcValue);
}
// Use a data contract as illustrated in the sample below to add composite types to service operations.
[DataContract]
public class DataContract1
{
string firstName;
string lastName;
[DataMember]
public string fname
{
get { return firstName; }
set { firstName = value; }
}
public string lname
{
get { return lastName; }
set { lastName = value; }
}
}
I have edited my web.config file, and added these lines (I read it in black book)
<service name="Service" behaviorConfiguration="ServiceBehavior">
<!--Service EndPoints-->
<endpoint address="" binding="wsHttpBinding" contract="MyServices">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadatExchange"/>
</service>
Here is my system.servicemodel code
<system.serviceModel>
<services>
<!-- My Custimization -->
<service name="Service" behaviorConfiguration="ServiceBehavior">
<!--Service EndPoints-->
<endpoint address="" binding="wsHttpBinding" contract="MyServices">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadatExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https"/>
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
</system.serviceModel>