Mitch
Mitch

Reputation: 389

Need to create service interface class for WCF service.

Here is a snippet of the code file I am trying to generate. This is an older WCF project, so I am not familiar. With the new service projects I simply right click and choose update service references.

using System;
`//-------------------------------------------------------------------------
-----
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.269
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//--------------------------------------------------------------------------
----


[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", 
"4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(ConfigurationName = 
"IBusinessService")]
[CLSCompliant(false)]
public interface IBusinessService
{

[System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IBusinessService/Receive_Replenishment_Request", ReplyAction = "http://tempuri.org/IBusinessService/Receive_Replenishment_RequestResponse")]
int Receive_Replenishment_Request(System.Nullable<int> Module, System.Nullable<int> Level, System.Nullable<int> Side, System.Nullable<int> Row, string User);

This file is in a separate project than the BusinessService.cs and IBuesinessService.cs which has the [ServiceContract] attribute.

Is there a tool that I have to run to generate the service reference class? I need to update this service reference.

Upvotes: 1

Views: 1544

Answers (1)

CodeCaster
CodeCaster

Reputation: 151720

As far as I know, the "Add Service Reference" window is a mere wrapper for Svcutil (or they call into the same APIs). You can execute that tool from a command prompt.

If your service you want to generate a client for actually runs and exposes metadata, it's as simple as

svcutil http://service/metadataEndpoint

To generate the "proxy", the classes and data types that form the service client.

If you can't run the service, or if it can't expose metadata, I guess you need to export metadata from the assembly containing the service to .wsdl and .xsd files:

svcutil.exe ServiceAssembly.dll

Then generate a client from those files:

svcutil.exe YourServiceName.wsdl

See also How to generate WCF service with SvcUtil.exe.

Upvotes: 2

Related Questions