English 中文(简体)
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 handle 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.





相关问题
Python SOAP server / client

I have a problem with Python and SOAP. I need to create a web service based on SOAP in Python. I read that I can use libraries like soaplib, suds and ZSI. I created a Hello World web service with ...

HTTP POST and complex structures

I m trying to send a complex HTTP POST request to a web service. The web service was created using VS2008, in which you can set VS to create HTTP POST and GET interfaces alongside the SOAP one. Now ...

XML-RPC Standard and XML Data Type

I was looking at XML-RPC for a project. And correct me if I m wrong, but it seems like XML-RPC has no XML datatype. Are you supposed to pass as a string? or something else? Am I missing something? ...

Most appropriate API for URL shortening service

I ve just finished an online service for shortening URLs (in php5 with Zend Framework); you can enter an URL and you get an short URL (like tinyurl and such sites). I m thinking about the API for ...

What is the best solution for creating a SOAP Server in PHP?

I need some advice on which library is the best choice when it comes to creating SOAP servers (and eventually SOAP clients) in PHP. I know there is built-in functions for this, but is that really the ...

Logging all Soap request and responses in PHP

Does anyone know how to log all request and responses with the builtin SoapClient in PHP? I could in fact manually log everything with SoapClient::__getLastRequest() and SoapClient::__getLastResponse()...

热门标签