web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Consuming a WCF Web Service which returns a composed type from AX2009

(0) ShareShare
ReportReport
Posted on by

Hi all,

 I need to consume a WCF Web Service which returns a composed type which is a list of objects with the following structure:

[Serializable]

    public class Title

    {

        public Title()

        {

            ExternalLibraryID = string.Empty;

        }

        public string TitleID { get; set; }

        public string ItemID { get; set; }

        public string Country { get; set; }

        public string Language { get; set; }

        public string Description { get; set; }

 

        public string ExternalLibraryID { get; set; }

        public string Runtime { get; set; }

        public string DueDate { get; set; }

    }

 The definition of the service is this:

namespace TestServiceWCF

{

    [ServiceContract]

    public interface ITestServiceService

    {

        [OperationContract]

        TestServiceResponse GetTitles(TestServiceRequest request);

 

    }

 

    [DataContract]

    public class TestServiceRequest

    {

        [DataMember]

        public string FilePath { get; set; }

 

        [DataMember]

        public Customers Customer { get; set; }

    }

 

    [DataContract]

    public class TestServiceResponse

    {

        [DataMember]

        public List<Title> Titles { get; set; }

       

    }

} 

 

 If I am testing the web service from a .NET client everything works just well because I am able to serialize the response of the web service and write it to a file using :

XmlSerializer x = new XmlSerializer(response.GetType());

 

      using (TextWriter writer = new StreamWriter(fileName))

      {

            x.Serialize(writer, response);

            writer.Flush();

            }

I am trying to do the same thing in AX but it seems that the response object is NULL when tested with

CLRInterop::IsNull(response)

method and the processing of the response is interrupted.

I found on this forum, an older post from  Mohammed Rasheed saying that the response of the web service should be collected in a CLRObject and the transferred to a AX container with

con = ClrInterop::getAnyTypeForObject(clrObject);

I've tried that also but I'm getting errors like this when I am trying to get the web service response directly into a ClrObject type variable.

Type 'System.ServiceModel.Channels.ReceivedFault' in assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.

 It looks like I need to set something more on the web service configuration but I do not know what exactly.

 

Any help will be greatly appreciated.

Best regards,

Sorin

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    Hi, do you remember how fix this problem? I have the same problem. Can you help me? Thanks

  • Martin Dráb Profile Picture
    237,948 Most Valuable Professional on at

    I don't think you can get ReceivedFaults while using service references in AOT, but you can create a service client in Visual Studio and use it as any other .NET library via CLR Interop to X++. Also check my blog post ReceivedFault is not marked as serializable.

  • Community Member Profile Picture
    on at

    Oh, ok, thank you very much!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans