NLog Webservice Target - Soap envelope missing #1851

Open
blakatos opened this Issue Dec 14, 2016 · 7 comments

Projects

None yet

2 participants

@blakatos
blakatos commented Dec 14, 2016 edited
  • Bug

NLog version: (e.g. 4.2.3)
4.3.11

Platform: ..Net 4.5.2

Current NLog config (xml or C#, if relevant)

<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
      autoReload="true"
      throwExceptions="true"
      internalLogFile="c:\nLogDebugging.txt" internalLogLevel="Trace">

  <targets> 
    <target xsi:type="WebService"
            encoding=""
          name="EmailWebService"
          url="http://computername/TestWSForNLog2/MyWebService.asmx"
          namespace="http://namespace/webservices"
          methodName="SendMail2">
         <parameter layout="" name="from" type="System.String"/>
          <parameter layout="username@address.com" name="to" type="System.String"/>
          <parameter layout="" name="cc" type="System.String"/>
      </target>
  </targets>
  <rules>
    <logger name="*" minlevel="Debug" writeTo="EmailWebService" />
  </rules>
</nlog>

In case of a BUG:

  • What is the current result?
    When I call the webservice by adding a service reference is Visual Studio 2015 I see this in Fiddler:
POST http://computername/TestWSForNLog2/MyWebService.asmx HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 4.0.30319.42000)
VsDebuggerCausalityData: uIDPo4rtZBSuD1RGtQzXHA48wAcAAAAAIyg/V4GZak2tTxbfdqq1CxRIDzCgKRhOpp04ElhwUo0ACQAA
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://namespace/webservices/SendMail2"
Host: computername
Content-Length: 327
Expect: 100-continue

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><SendMail2 xmlns="http://namespace/webservices"><from /><to>username@address.com/to><cc /></SendMail2></soap:Body></soap:Envelope>

However, when I call the logger and use the above target, Fiddler catches this session from NLog. Which is missing the Soap Envelope:

POST http://computername/TestWSForNLog2/MyWebService.asmx HTTP/1.1
SOAPAction: http://namespace/webservices/SendMail2
Content-Type: text/xml; charset=utf-8
Host: computername
Content-Length: 254
Expect: 100-continue

Here is the code which generates the NLog call:

logger.Log(LogLevel.Error, "This is my message");

logger is defined at the top of the class:

private static Logger logger = LogManager.GetCurrentClassLogger();

The computername above refers to another PC on our network where I have the webservice hosted for development. When I break point the webservice on computername, the break point is hit when called from the service reference, but not when called through NLog.

Any help is appreciated. I am stuck, having tried everything I can think of and google.

@304NotModified
Member
304NotModified commented Dec 14, 2016 edited

are we missing the whole body?

**Note: In the envelope above I had delete the "<"'s. If I didn't the text wasn't being displayed properly.

Could you post it in the code blocks? See https://help.github.com/articles/creating-and-highlighting-code-blocks/ - I have partially fixed it already.

Could you also test with NLog 4.4? (just released) - thx!

@blakatos

Thank you 304NotModified. I have corrected the rest of the formatting.

As far as I can tell from using Fiddler, the whole body is missing. I have posted in the original post everything from the Raw tab in Fiddler.

@blakatos

I upgraded to version 4.4, but unfortunately the results are the same.

@304NotModified
Member

Thanks for testing.

There are unit tests which using the web service target (and sent them to local), which are succeeding. I'm pretty sure the web service target does work.

I will check why fiddler won't show the body

@blakatos

Hello 304NotModified,
Were you able to determine if there is anything wrong with what I am doing?
Thanks

@304NotModified
Member

Unfortunately no, but I'm pretty sure the webservice target does work (as the unit test is also starting up a Owin service)

@304NotModified 304NotModified self-assigned this Dec 21, 2016
@304NotModified
Member
304NotModified commented Jan 14, 2017 edited

sorry this issue is low on my list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment