admin管理员组

文章数量:1405393

I'm new to working with WCF. I'm currently at the point where I'm implementing the MessageContactAttribute. This class is located in its own separate project and referenced when needed.

[MessageContract(IsWrapped = true, WrapperName = "JournalTransactionRequestObject", 
WrapperNamespace = "/")]
public class JournalTransactionRequestInfo : IJournalTransactionRequestInfo 
{
    [MessageHeader(Namespace = "/")]
    public string LicenseKey {  get; set; }
}

The service is currently hosted by a console app and it seems to run fine. My problem is in the client. When I generate the service proxy, it creates its own JournalTransactionRequestInfo class as opposed to referencing the already existing one.

Is there a way I could make the client reference the class that I made specifically? I don't seem to have this problem with the DataContact attribute. I've checked the 'Reuse types in all referenced assemblies' option in the configuration.

Am I missing anything?

I'm new to working with WCF. I'm currently at the point where I'm implementing the MessageContactAttribute. This class is located in its own separate project and referenced when needed.

[MessageContract(IsWrapped = true, WrapperName = "JournalTransactionRequestObject", 
WrapperNamespace = "https://www.something/")]
public class JournalTransactionRequestInfo : IJournalTransactionRequestInfo 
{
    [MessageHeader(Namespace = "https://www.something/")]
    public string LicenseKey {  get; set; }
}

The service is currently hosted by a console app and it seems to run fine. My problem is in the client. When I generate the service proxy, it creates its own JournalTransactionRequestInfo class as opposed to referencing the already existing one.

Is there a way I could make the client reference the class that I made specifically? I don't seem to have this problem with the DataContact attribute. I've checked the 'Reuse types in all referenced assemblies' option in the configuration.

Am I missing anything?

Share Improve this question asked Mar 23 at 19:23 TimTim 457 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Make sure your client project references the assembly that contains your JournalTransactionRequestInfo class (and any other shared contracts). This ensures the client get the class you want to reuse.

You can also try adding a service reference using VS by following these steps :

  1. In your client project, right-click on the project and choose Add Service Reference.

  2. Enter the service URL and click Go.

  3. Before clicking OK, click the Advanced… button.

  4. In the Advanced Settings dialog, locate the Reuse types in referenced assemblies option.

  5. Ensure that your shared contract assembly is referenced by the client and that it appears in the list of assemblies to reuse types from. Check the box to reuse types found in these assemblies.

本文标签: cCan I reference a MessageContract as a reuse typeStack Overflow