views:

436

answers:

2

I have a WSDL file defining a service that I have to implement in WCF. I had read that I could generate the proxy using svcutil from the WSDL file, and that I could then use the generated interfaces to implement the service.

Unfortunately, I can't quite seem to find a way to have the interfaces contain the correct attributes to expose the contracts.

All operations have the "OperationContractAttribute" attribute, but it appears as though for the service to be exposed, I require the "OperationContract" for each one. Same thing with "ServiceContractAttribute" and "ServiceContract", and I imagine DataContract, but I haven't gotten that far.

I could manually make these changes, but I would much prefer a technique where the existing code could be easily used, or better code could be generated for my uses. Is there some way that this can be done?

Thanks.

EDIT:

Issue on Microsoft Connect

Command used:

svcutil ObjectManagerService.wsdl /n:*,Sample  /o:ObjectManagerServiceProxy.cs /nologo

Code sample:

public interface ObjectManagerSyncPortType
{

    // CODEGEN: Generating message contract since the operation createObject is neither RPC nor document wrapped.
    [System.ServiceModel.OperationContractAttribute(Action="http://www.sample.com/createObject", ReplyAction="*")]
    [System.ServiceModel.XmlSerializerFormatAttribute()]
    Sample.createObjectResponse1 createObject(Sample.createObjectRequest1 request);
    // ...
}

As best as I can tell/see the WSDL file is entirely self-contained and requires no additional XSD files.

+1  A: 

I don't see any problem with the code that was generated, really:

public interface ObjectManagerSyncPortType
{

    // CODEGEN: Generating message contract since the operation createObject is neither RPC nor document wrapped.
    [System.ServiceModel.OperationContractAttribute(Action="http://www.sample.com/createObject", ReplyAction="*")]
    [System.ServiceModel.XmlSerializerFormatAttribute()]
    Sample.createObjectResponse1 createObject(Sample.createObjectRequest1 request);

This is absolutely, totally valid code - try it! I'm pretty sure it runs.

All operations have the "OperationContractAttribute" attribute, but it appears as though for the service to be exposed, I require the "OperationContract" for each one.

Using [OperationContract] is just a short-hand notation (which is true and valid and useable for any .NET attribute, really - nothing special about the WCF attributes here) and is 100% equivalent to [OperationContractAttribute]. I don't see any issues there.

marc_s
It seems that the (Action="http://www.sample.com/createObject", ReplyAction="*") part is the thing that is messing things up, but I don't really understand why. If I delete that from the interface, and just have [OperationContractAttribute], the operation shows up fine in the WSDL when visiting the service, otherwise it isn't visible.
chtmd
A: 

So it turns out that ReplyAction="*" is the culprit. Thanks for help though.

chtmd
@chtmd: could you please report this on Connect, at http://connect.microsoft.com/visualstudio? Once you're done, edit this answer to include the link to the Connect bug report so we can vote on how important we feel a fix would be.
John Saunders
I created the issue and added the link above.
chtmd