Debugging an web service call to the service tier

tedcjohnstontedcjohnston Member Posts: 41
edited 2010-04-14 in NAV Three Tier
Is there a way to get the web service to dump copies of XML files at each http post? (Not sure if this even makes sense, sorry if it does not.)

I'm working with an external vendor who is inserting a sales order via a web service. He is trying to mix Item and Resource lines. When he tries just items it works. When he tries items and resources he gets an error saying the resource with the item number cannot be found. He claims he is not sending the type. I would like to be able to dump the XML as it comes it to see from my side what he is sending.

Does this make sense?
"There are only two truly infinite things: the universe and stupidity. And I am unsure about the universe." - Albert Einstein
Corollary- Build and idiot proof system and nature will build a better idiot.

Comments

  • ara3nara3n Member Posts: 9,256
    If he is not sending the type, then I guess he should?

    The only way I can see the message is to use packet sniffer software like wireshark.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • tedcjohnstontedcjohnston Member Posts: 41
    Would be a very nice feature to help troubleshoot issues- especially with outside programmers.

    A debugging flag set on the Service Tier that dumped the XML into a directory would be very helpful.
    "There are only two truly infinite things: the universe and stupidity. And I am unsure about the universe." - Albert Einstein
    Corollary- Build and idiot proof system and nature will build a better idiot.
  • ara3nara3n Member Posts: 9,256
    they should be using SOAPUI and see how the xml file should be generated.

    In IE you save the WSDL for the webservice as xml file. Then in SOAPUI you open that file. It will show you how to generate the xml file.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • eknraweknraw Member Posts: 26
    I've used a combo of wireshark and some custom code to dump my XML DOM object to disk. I also use the built in WCF logging features described below.

    Look for Microsoft.Dynamics.Nav.Server.exe.config in directory: C:\Program Files\Microsoft Dynamics NAV\60\Service. If it's a x64 system the Program Files might look like "Program Files (x86)". With this file you can turn on the tracing and message logging feature of a WCF service. You'll be able to see the messages at the transport and service level layers as well as the traces which is handy in finding errors kicked out in the service tier. It's not perfect but it's the best visibility I've found as what's going on at the service tier. You can then use the Microsoft Service Trace Viewer (svctraceviewer.exe) to view these log files. On my dev box this is located at C:\Program Files\Microsoft SDks\Windows\v6.0A\Bin. I think this might be part of the Visual Studio install.

    If you have Visual Studio you can find a tool to edit this .config file. Tools -> WCF Service Configuration Editor. That makes it easy to turn stuff on and off. Otherwise you'll have to be familiar with editing the config by hand.

    This might be a bit hacked up but it would look something like this:
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
    
      <system.diagnostics>
        <assert assertuienabled="false" />
        <sources>
           <source name="System.ServiceModel" switchValue="Warning,ActivityTracing"
            propagateActivity="true">
            <listeners>
              <add type="System.Diagnostics.DefaultTraceListener" name="Default">
                <filter type="" />
              </add>
              <add name="ServiceModelTraceListener">
                <filter type="" />
              </add>
            </listeners>
          </source>
          <source name="System.ServiceModel.MessageLogging" switchValue="Verbose,ActivityTracing">
            <listeners>
              <add type="System.Diagnostics.DefaultTraceListener" name="Default">
                <filter type="" />
              </add>
              <add name="ServiceModelMessageLoggingListener">
                <filter type="" />
              </add>
            </listeners>
          </source>
    
    
        </sources>
        <sharedListeners>
          <add initializeData="C:\NAV Service Logs\Microsoft.Dynamics.Nav.Server_tracelog.svclog"
            type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            name="ServiceModelTraceListener" traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack">
            <filter type="" />
          </add>
          <add initializeData="C:\NAV Service Logs\Microsoft.Dynamics.Nav.Server_messages.svclog"
            type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            name="ServiceModelMessageLoggingListener" traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack">
            <filter type="" />
          </add>
        <trace autoflush="true" />
      </system.diagnostics>
      <system.serviceModel>
        <diagnostics wmiProviderEnabled="true" performanceCounters="All">
          <messageLogging logEntireMessage="true" logMalformedMessages="true"
            logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" />
        </diagnostics>
      </system.serviceModel>
    
    </configuration>
    

    I've also been experimenting with this project: http://ukadcdiagnostics.codeplex.com/ and sending these WCF logs to a SQL table. It does add a bit of overhead to web service calls and I'm not sure I'd put it in a production environment but it's sometimes easier than using the WCF trace viewer.

    Bill
Sign In or Register to comment.