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 :
Finance | Project Operations, Human Resources, ...
Unanswered

How to be able to receive an XML in D365 using a custom D365 Web Service?

(0) ShareShare
ReportReport
Posted on by 5

Currently working on an implementation where an external API will be posting information to D365 FO. I've implemented something similar using a data contract in X and using this as the parameter for the service method.


using System.Net;

class NmbGtwTmsReceiver
{
    //WHAT NEEDS TO BE INCLUDED IN THE PARAMETER HERE?
    public HttpStatusCode processXMLPost() 
    {
        
        return HttpStatusCode::OK;
    }

}

But if D365 is receiving an XML, do I need to use a data contract? I tried using an external C# class as the parameter and tried posting a sample xml file to this endpoint and it returns a deserialization error. There is an issue with the parameter I am using. 

{
    "Message""An exception occurred when deserializing the request - Exception occurred when parsing the request content - Unexpected character encountered while parsing value: <. Path '', line 0, position 0.",
    "ExceptionType""XppServicesDeserializationException",
    "ActivityId""86f94c34-622a-0003-c059-fa862a62d901"
}
The current behavior noticed from using JSON is that the parameter name in this method needs to be a field in the incoming JSON of the request. An example is this, when my function header is:
  • "public HttpStatusCode processXMLPost(SampleDataContract _data) {}

Then inside the request being sent to this service function, the json needs to be:

{
    _data: "DATA"
}

If the above is what is needed, how would I be able to do this for XML data or is there a way to get the full request object as a parameter or a different type of parameter needed?
I have the same question (0)
  • Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at

    If you use the JSON endpoint, you need to provide a JSON object. The object may have a single string property, where you'll provide an XML string.

    Another option is using the SOAP endpoint. SOAP uses XML, but you must respect its structure, which probably isn't what you want.

    Yet another option is transforming the message before calling F&O. For example, you could convert your XML to JSON before calling the JSON endpoint of an F&O custom service.

  • ZDevFO Profile Picture
    5 on at

    Thanks for the quick response Martin. I'm trying to figure out if transforming the message before calling F&O is possible but on to the point of using the SOAP Endpoint. Can you provide more details on this? How would I be able to set this up or use this in D365?

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

    If look at Custom service development documentation page, it starts with saying:

    You can develop custom services for finance and operations. When a developer writes a custom service under a service group, the service group is always deployed on two endpoints:

    • SOAP endpoint
    • JSON endpoint

    SOAP-based custom service

    SOAP-based services remain the same as they were in Dynamics AX 2012.

    Code examples for consuming custom services using SOAP are available in the Microsoft Dynamics AX Integration GitHub repository.

    Are these the details you're looking for?

  • ZDevFO Profile Picture
    5 on at

    Yes I started to look at this page thanks but do you know if we can do this within D365 using X++ classes to create the SOAP endpoint? I'm not sure of the differences of how to develop the JSON and SOAP endpoint with X++ classes.

    And another note, I know when wanting to view the list of active services it can be done by using the standard D365 URL with "api/services" at the end. I can see the active ones for my environment when I do this but when I try to end it with "soap/services", the page doesn't load because it can't be found and results in an HTTP 404 error on the browser.

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

    Yes, it's possible - the documentation isn't lying to you.

    You need to create a class with a method, use it as a service operation and put the service to service group. Then, as I quoted above, your custom service is deployed to both endpoints (SOAP and JSON) and you can use either of them.

    As you you've found, there is no "soap/services" endpoint.

  • ZDevFO Profile Picture
    5 on at

    So currently I have a custom service that is active but I can only see this under the api/services endpoint. How would I access this endpoint using SOAP?

    Also if the service is expecting an XML, can I use a C# class representing the XML as the parameter or does it need to be a data contract in X++?

    class XMLReceiver

    {

       public HttpStatusCode processXMLPost() //What should be here and how do I send an XML Post to the SOAP version?

       {

           return HttpStatusCode::OK;

       }

    }

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

    You won't use the JSON endpoint when you want the SOAP endpoint. Let me quote the documentation once more:

    Example endpoint for a dev environment

    usnconeboxax1aos.cloud.onebox.dynamics.com/.../UserSessionService

    Example endpoint for a non-dev environment

    https://<baseurl>/soap/services/UserSessionService?wsdl

    For more information about custom services, see:

    If you want a complex parameter, you need a data contract class (not just "a" class). I don't know if it accepts a contract defined in C#. You may try it, but you should learn the basics first, therefore stick to X++ code for now at least.

    I don't know what you mean by "how do I send an XML Post to the SOAP version"? Are you saying that you don't know how to use SOAP protocol at all? First of all, did you see the sample code repository that I shared before?

  • ZDevFO Profile Picture
    5 on at

    Nevermind, I now see the endpoint is using the Service Group name to be able to reach it. Is the parameter the only way to be able to access the body coming in? Is there a way to access headers of the incoming request?

    Also, I will have to include additional headers such as "SOAPAction"? 

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

    What your X++ method receives is the parameter of the method, nothing else. Put the information you need to the contract.

    SOAPAction is used by the protocol; it's not a part of the data for your service operation. Why would you be interested in it in X++?

  • ZDevFO Profile Picture
    5 on at

    Sorry to clarify I meant I would like to test this SOAP endpoint now that I see it exists. I see additional information like SOAPAction, Binding, etc when I look at the details of the SOAP endpoint. I am wondering what I need to include in Postman to send it and try to trigger the breakpoint I have at the start of my service method. SOAPAction should be something I send but would it just be a "POST"? There is a different value in the SOAPAction field on the SOAP endpoint.

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 664 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 522 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans