Quantcast
Channel: WCF, ASMX and other Web Services
Viewing all articles
Browse latest Browse all 555

create service skelton from WSDL file

$
0
0

Hi i want to know how the skelton of Service created from a WSDL file

for example i have a created a simple WCF Service

IService.cs

using System;
using System.Data;
using System.ServiceModel;

[ServiceContract]
public interface IService
{
	[OperationContract]
	DataTable DoWork();
}

Service.cs

using System;
using System.Data;
using System.ServiceModel;

public class Service : IService
{
	public DataTable DoWork()
	{
        DataTable dt = new DataTable();
        DataRow dr = dt.NewRow();
        dr["Name"] = "Tza";
        dt.Rows.Add(dr);
        dt.AcceptChanges();
        return dt;
	}
}

Above service returns me the url: http://localhost/TestWCFService1/Service.svc?wsdl

For create skelton i try the command svcutil http://localhost/TestWCFService1/Service.svc?wsdl which returns me a service.cs and output.config file

using System.Data;

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(ConfigurationName="IService")]
public interface IService
{
    
    // CODEGEN: Parameter 'DoWorkResult' requires additional schema information that cannot be captured using the parameter mode. The specific attribute is 'System.Xml.Serialization.XmlElementAttribute'.
    [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IService/DoWork", ReplyAction="http://tempuri.org/IService/DoWorkResponse")]
    [System.ServiceModel.XmlSerializerFormatAttribute()]
    DoWorkResponse DoWork(DoWorkRequest request);
}

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(WrapperName="DoWork", WrapperNamespace="http://tempuri.org/", IsWrapped=true)]
public partial class DoWorkRequest
{
    
    public DoWorkRequest()
    {
    }
}

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(WrapperName="DoWorkResponse", WrapperNamespace="http://tempuri.org/", IsWrapped=true)]
public partial class DoWorkResponse
{
    
    [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://tempuri.org/", Order=0)]
    [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
    public System.Data.DataTable DoWorkResult;
    
    public DoWorkResponse()
    {
    }
    
    public DoWorkResponse(System.Data.DataTable DoWorkResult)
    {
        this.DoWorkResult = DoWorkResult;
    }
}

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public interface IServiceChannel : IService, System.ServiceModel.IClientChannel
{
}

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public partial class ServiceClient : System.ServiceModel.ClientBase<IService>, IService
{
    
    public ServiceClient()
    {
    }
    
    public ServiceClient(string endpointConfigurationName) : 
            base(endpointConfigurationName)
    {
    }
    
    public ServiceClient(string endpointConfigurationName, string remoteAddress) : 
            base(endpointConfigurationName, remoteAddress)
    {
    }
    
    public ServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : 
            base(endpointConfigurationName, remoteAddress)
    {
    }
    
    public ServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : 
            base(binding, remoteAddress)
    {
    }
    
    [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
    DoWorkResponse IService.DoWork(DoWorkRequest request)
    {
        return base.Channel.DoWork(request);
    }
    
    public System.Data.DataTable DoWork()
    {
        DoWorkRequest inValue = new DoWorkRequest();
        DoWorkResponse retVal = ((IService)(this)).DoWork(inValue);
        return retVal.DoWorkResult;
    }
}



which is the skelton file for service if i am not wrong, but i dont know how do i create a skelton with above file which returns to me by svcutil command

orignal file contains simple neet and clean code but the code provide by svcutil is very long, i unable to understand

Please advice how i create a skelton from wsdl file

Thank you


Viewing all articles
Browse latest Browse all 555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>