using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
namespace PackingSlipService
{
/// <summary>
/// Summary description for PackingSlip data service
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public IEnumerable<PackingSlipServiceReference.BM_PODResponseContract> getDeliveryNotes(
string company,
string lorryId,
DateTime deliveryDate
)
{
// define variables
PackingSlipServiceReference.BM_PODRequestContract appRequest = new PackingSlipServiceReference.BM_PODRequestContract();
PackingSlipServiceReference.BM_PackingSlipServiceClient packSlipService = new PackingSlipServiceReference.BM_PackingSlipServiceClient();
IEnumerable<PackingSlipServiceReference.BM_PODResponseContract> deliveryNoteList = new List<PackingSlipServiceReference.BM_PODResponseContract>();
PackingSlipServiceReference.CallContext context = new PackingSlipServiceReference.CallContext();
// set parameter values
appRequest.parmLorryId = lorryId;
appRequest.parmDeliveryDate = deliveryDate;
context.Company = company;
// send these to service and get result
deliveryNoteList = packSlipService.getDeliveryNotes(context, appRequest);
// return list of delivery note data contracts
return deliveryNoteList;
}
}
}
Above is the code I have written inside the web service wrapper. This is simply for testing the return of data.
My issue relates to the fact that I have declared the IEnumerable list type set to that of my custom data contract type. I have correctly declared this contract inside AX with DataContractAttributeType and DataMemberAttributeType assigned to both parameters which are included in the contract:
On the getDeliveryNotes method in AX this is what the header is set to:
[SysEntryPointAttribute(true),
AifCollectionTypeAttribute('PODRequest', Types::Class, classStr(BM_PODRequestContract)),
AifCollectionTypeAttribute('return', Types::Class, classStr(BM_PODResponseContract))]
It takes the request contract and then returns the response contract.
This all works fine in the C# console app but when I try to test this as a web service wrapper it gives me the original error.
I suppose my question is what to do so that my return type custom service data contract type is recognisable and can be returned with data without error through the web service?