exposing Entity/EntityCollection through WCF problems

Posts   
 
    
mvlootman
User
Posts: 3
Joined: 20-May-2008
# Posted on: 20-May-2008 14:41:56   

used version: LLBLGen Pro 2.5 Final selectedPreset: SD.Preset.Adapter.TwoClasses (with SD.Tasks.Adapter.Webservices.WebserviceHelperClassGenerator and WebServices.SchemaImporter)

I'm trying to use a WCF Web Service to pass specific Entity objects and EntityCollections, for use in the UI-layer. The problem I have is that the service reference generated by Visual Studio doesn't show the correct type.

Here the code I used:

  • Created a ServiceContract:

    [ServiceContract] public interface IService1 { [OperationContract] CustomerEntity GetCustomer(int customerId); }

  • Implement the WCF Service: public class Service1 : IService1 { public CustomerEntity GetCustomer(int customerId) { CustomerEntity customer = new CustomerEntity(1);

        using(DataAccessAdapter da = new DataAccessAdapter())
        {
            da.FetchEntity(customer);
        }
    
        return customer;
    }
    

    }

  • Resulting service reference (part)

    [System.Diagnostics.DebuggerStepThroughAttribute()] [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] [System.ServiceModel.MessageContractAttribute(WrapperName="GetCustomerResponse", WrapperNamespace="http://tempuri.org/", IsWrapped=true)] public partial class GetCustomerResponse {

    [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://tempuri.org/", Order=0)]
    [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
    public System.Xml.XmlElement GetCustomerResult;
    
    public GetCustomerResponse() {
    }
    
    public GetCustomerResponse(System.Xml.XmlElement GetCustomerResult) {
        this.GetCustomerResult = GetCustomerResult;
    }
    

    }

This deserializes the type to a System.Xml.XmlElement(?).

I've tried the example found in the customer section, which works. But when I add a WCF Web Svc and implement the INorthwindService. The resulting reference.cs in a client app, shows an object reference (instead of IEntity2)

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.ServiceModel.MessageContractAttribute(WrapperName="GetOrderAndCustomerWithHighestPriceResponse", WrapperNamespace="http://tempuri.org/", IsWrapped=true)]
public partial class GetOrderAndCustomerWithHighestPriceResponse {

    [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://tempuri.org/", Order=0)]
    [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
    public object GetOrderAndCustomerWithHighestPriceResult;

    public GetOrderAndCustomerWithHighestPriceResponse() {
    }

    public GetOrderAndCustomerWithHighestPriceResponse(object GetOrderAndCustomerWithHighestPriceResult) {
        this.GetOrderAndCustomerWithHighestPriceResult = GetOrderAndCustomerWithHighestPriceResult;
    }
}

Is it possible to create a WCF Web application and expose the Entity/EntityCollection (or IEntit2y/IEntityCollection2)? confused If more information is needed or code please let me know.

Thanks in advance!

Michiel.

goose avatar
goose
User
Posts: 392
Joined: 06-Aug-2007
# Posted on: 20-May-2008 19:18:41   

Please take a look to our WCF example in the examples section.

mvlootman
User
Posts: 3
Joined: 20-May-2008
# Posted on: 21-May-2008 09:07:00   

goose wrote:

Please take a look to our WCF example in the examples section.

As I said in the opening post, I have looked at the WCF example from the exampled section. This works fine, however when I try and modfy the example so it uses WCF Web Service instead of Remoting, it doesn't create the required web service reference (on the client).

I would like to expose the ServiceInterface as a WCF SOAP Web Service (using wsHttpBinding).

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 21-May-2008 09:36:38   

In the WCF example, please check the following:

1- The ReadMe file. Especially the following sections: - How to Install, IIS hosting - How To Run, no IIS hosting

2- The IIS wsHTTPBindings folder.

mvlootman
User
Posts: 3
Joined: 20-May-2008
# Posted on: 27-May-2008 11:59:13   

Walaa wrote:

In the WCF example, please check the following:

1- The ReadMe file. Especially the fololowing sections: - How to Install, IIS hosting - How To Run, no IIS hosting

2- The IIS wsHTTPBindings folder.

Thanks, I have the WCF Service running using wsHTTPBindings. It seems that I shouldn't add a Service Reference within Visual Studio but just use the interface from the service (INorthwind).

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 27-May-2008 12:41:50   

Exactly.