Logging External Web Services called from X++

I’ve followed the standard tutorials to create an external web service reference. My calls contain transactional data and logging is imperative. I’d like to know what sort of logging I should employ when making these external calls. I’d really love to have these calls appear in-line with standard AIF document history & exceptions, but I don’t think that’s easily feasible. I also can’t find the SOAP request and response generated by my external service reference, making the logging even trickier. I’ve thought about creating a custom outbound adapter, but I’m not sure if that’s the right approach. Just want to see what you professionals recommend.

https://technet.microsoft.com/en-ca/library/hh500185.aspx

http://daxmusings.codecrib.com/2011/10/consuming-external-webservices-in-ax.html

You can implement any logging you like. You should first look at your functional requirements.

AIF exceptions are stored in a normal table, so you can easily write into it. There is also a class (SysExceptionLog) to help with that. I’m not sure what you want to see in document history, if you’re not using document services.

Please explain what you mean by *"*I also can’t find the SOAP request and response generated by my external service reference" and what you’re trying to achieve with these messages.

Thanks for replying Martin!
I’m receiving requests through one of our custom services, within that method I need to call an external web service. I’d like all the logs to appear in one place, AIF ‘History’. (The form is called AifDocumentHistory, which is why the word document crept in, even though I’m implementing a custom web service, not a document service). I’m less concerned about the exceptions, since the logic is already in an AIF method, any exceptions thrown will get logged to the exception log.

The form AIF ‘History’ (AifDocumentHistory) links through to ‘Document Logs’ (AifDocumentLog) then subsequently ‘View XML’ (AifXmlViewer) to display the actual XML message that was received & sent (inbound ports), sent (outbound ports). I was looking for the request and response xml for similar logging purposes, but I may not have access to it if it’s generated outside X++ by the C# project, correct?

Another obstacle I’m facing is accessing the MessageID inside my Custom Service Operation. Since it’s used for idempotence I’d like to include the MessageID in my logs. Is it possible to access the Call Context object from inside my Custom Service Operation?

Some of these hurdles appear significant, and I’m wondering if there’s a different approach I should be taking? A custom outbound adapter? Your feedback is appreciated!

Do I understand correctly that you’re calling an external WCF service from an inbound operation of a custom AX service? How is the inbound service called?

You’ll find some options for getting SOAP messages in WCF explain in StackOVerflow: How do I get the XML SOAP request of an WCF Web service request?.

Message ID is in header, so you can’t access it from inside the operation. You would have to do in at a higher level.

Yes that’s correct, I’m calling an external WCF from an inbound custom AX service. My custom service is deployed to iis with the HTTP adapter. Another team here is consuming the WSDL using JAVA.