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.
Then inside the request being sent to this service function, the json needs to be:
{ _data: "DATA" }
Hi Martin, to follow up on this topic after some testing and investigations.
Let's say the soap xml looks like this:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="schemas.xmlsoap.org/.../">
<soap:Body>
<LeanXML xmlns="http://tempuri.org">
<Load CreateDate="03/27/2023 20:01:01.125" ExecutionEvent="Load Modified" ExecutionEventID="LM">
<LoadNum>6159</LoadNum>
<LoadID>6159</LoadID>
</Load>
</LeanXML>
</soap:Body>
<soap:Envelope>
The service method name requires to be LeanXML in order for my endpoint to trigger. I did the WSDL and got the correct one.
My issue now is my data contract contains no data.
Sure I will proceed with this step. Thanks for the help on this topic, very appreciated.
Again, my recommendation is starting with service client classes generated by Visual Studio, which will create and send the right request for you. Then you can take the message and use it in Postman.
You can see that trying to do it by yourself without learning SOAP isn't very successful, therefore maybe you should consider changing your approach.
Thanks, I understand this now.
I've noticed by a test to the soap endpoint using Postman, I am getting an error where it is expecting the body element of the SOAP request to be the name of the Service Name.
Example: Service operation name is "processSOAPXml". The error being returned is:
Type: System.ServiceModel.CommunicationException
Message: Error in deserializing body of request message for operation 'processSOAPXml'. OperationFormatter encountered an invalid Message body. Expected to find node type 'Element' with name 'processSOAPXml' and namespace 'http://tempuri.org'. Found node type 'Element' with name 'eb:Plan' and namespace 'www.oasis-open.org/.../faultstring>
Let me repeat: you create a custom service in F&O and it gets automatically deployed to both the JSON-based endpoint and the SOAP endpoint. Therefore you don't need to do anything for the SOAP service than creating a custom service in F&O. That's the part of creating the web service. The other half is actually calling the service. For example, you can let Visual Studio to generate a service client and call a web service through this client. You can find a sample in the GitHub repository mentioned before.
I want to confirm my understanding thus far:
- An external service will be able to send communicate via SOAP to D365 by a POST request to the /soap/services/ServiceGroup endpoint (what is part of the SOAP request in order to follow protocols I don't know yet)
- It will be able to reach the service class and deserialize using the data contract in the parameter the same way it does when the JSON-REST endpoint is used (/api/services/..../....)
- A data contract can be used for XMLs
- My service and service group I've created are already deployed on the SOAP and REST endpoints
For the SOAP endpoint option, will I be able to only use an X++ service class and data contract class? Do I have to do anything outside in a C# to be able to do this? And when I mean SOAP transaction, I mean the request that is sent to D365, if you have a sample of how this would like with the different soap elements, this would be good.
I'm sorry, but I don't understand your question. Please elaborate.
Please see the updated message above.
And if I use the SOAP endpoint, I can do everything inside X++?
I'm sorry, but I'm not sure what you mean by a SOAP transaction and other elements.
I recommend starting with the sample code from Microsoft.
I have found out the external service I'm working with is able to send a SOAP request and would be ideal to do it this way.
Do you have a sample of a SOAP transaction or good resource online showing one so I can try to send it? If I have the URL endpoint to send to now that you've shown me how that part works with the soap/services/ServiceGroupName but I'm just not understanding how to use the other elements.
Also, I want to confirm my understanding thus far:
André Arnaud de Cal...
292,160
Super User 2025 Season 1
Martin Dráb
230,962
Most Valuable Professional
nmaenpaa
101,156