开发者

How do I get the details of a SOAP fault in Dynamics AX?

I'm currently communicating with an external SOAP service within AX using the a service reference and the generated .NET class. Everything is working out greatly with the exception of how to han开发者_StackOverflow中文版dle SOAP faults. Ideally, this doesn't happen, but sometimes the SOAP server (which I control as well) throws a SOAP fault with a "code" and a "message". Some examples of codes and their respective messages:

  • "INVALID_API_KEY" / "An invalid API key was used."
  • "INVALID_CUSTOMER_ID" / "An invalid customer Id was passed (%d)".

These error codes are defined in the WSDL, so when these faults are thrown I can naturally pass back some sanitized message to the user. Unfortunately, I'm having a problem drilling down through X++ to figure which SOAP fault has been thrown so that I can display back a sanitized explanation of failure back to my user. Currently my code looks like:

try
{
    new InteropPermission(InteropKind::ClrInterop).assert();   

    // ... code making SOAP calls

    CodeAccessPermission::revertAssert();
}
catch(Exception::CLRError)
{
    warning(AifUtil::getClrErrorMessage());
}

This handles the SOAP fault well enough, the error it produces is the following: " Type 'System.ServiceModel.Channels.ReceivedFault' in assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable."

I have tried drilling down the base .NET classes, but the ServiceModel (and subsequently) the other classes for translating the SOAP fault (FaultException down the class ladder) into a human readable message are obscured.

Can anyone lend me some insight on how best to get at the actual fault code/message? Thanks!


You could use wcf tracing http://msdn.microsoft.com/en-us/library/ms733025.aspx

Or you could check the response using a network sniffer like fiddler.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜