Results 1 to 2 of 2

Thread: [RESOLVED] wcf with a DataModel (edmx) file

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Dunmow,Essex,England
    Posts
    898

    Resolved [RESOLVED] wcf with a DataModel (edmx) file

    Hi All,

    I'm trying to create a WCF Data Layer using a DataModel. Concentrating on the model for the moment, I have imported a number of Stored Procs for use by the Data Layer. Taking one of the Stored Procs that Expects 3 parameters to be passed in, returns 6 values Decalred as Type Output in the SP Header. i.e

    Code:
    Create procedure myProc(@ClientId int, @ClientVersion int, @name varchar(50) output.....
    Now I have created a Function Imports that makes a reference to the SP and I have created a complex type which maps to the outputs of the SP.

    So now in my Interface declaring the Operation contract I have:

    Code:
     [OperationContract]
            ClientGetOccupationDetails GetOccupationDetails(Int32 UserID, Int32 ClientId, Int16 ClientVersion);
    Then in my Service class that implements the interface, I have:

    Code:
    public ClientGetOccupationDetails GetOccupationDetails(Int32 UserID, Int32 ClientID, Int16 ClientVersion)
            {
                AIS_DEVEntities Dev = new AIS_DEVEntities();
                
            }
    How do return my values.

    I have attached a screen shot of my Model Browser so that it might be clearer.
    Attached Files Attached Files

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Dunmow,Essex,England
    Posts
    898

    Re: wcf with a DataModel (edmx) file

    Ok, Because the SP has output parameters, I have declared my OperationContract as:

    Code:
            [OperationContract]
            void GetOccupationDetails(Int32 UserID, Int32 ClientId, Int16 ClientVersion, out Int32? OccupationID, out String Code, out String Name, out String Description, out String ABIClass, out Int32? RiskClassID);
    and in my Service Class I have:

    Code:
           public void GetOccupationDetails(Int32 UserID, Int32 ClientID, Int16 ClientVersion, out Int32? OccupationID, out String Code, out String Name, out String Description, out String ABIClass, out Int32? RiskClassID)
            {
                AIS_DEVEntities Dev = new AIS_DEVEntities();
    
                ObjectParameter oCCOccupationID = null;
                ObjectParameter oCode = null;
                ObjectParameter oName = null;
                ObjectParameter oDescription = null;
                ObjectParameter oABIClass = null;
                ObjectParameter oRiskClassID = null;
     
                Dev.spCCClientGetOccupationDetails(UserID, ClientID, ClientVersion, oCCOccupationID, oCode, oName, oDescription, oABIClass, oRiskClassID);
    
                OccupationID = Convert.ToInt32(oCCOccupationID);
                Code = Convert.ToString(oCode);
                Name = Convert.ToString(oName);
                Description = Convert.ToString(oDescription);
                ABIClass = Convert.ToString(oABIClass);
                RiskClassID = Convert.ToInt32(oRiskClassID);
    
                Dev.Dispose();
            }
    When I try and run this in the WCF Service Test Client (f5) and then enter valid values for the 3 input parameters (UserID, ClientID,ClientVersion) it errors with: the parameter at index 3 in the parameters array is null.

    It would be because that is my first output param (cCoccupationID). This is on the Call to Dev.spCCClientGetOccupationDetails.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width