Remove ActivityId from WCF Request

好久不见. 提交于 2019-12-21 04:19:18

问题


I'm having an interesting compatibility issue between a WCF client and a Java web service. In short I've found that the way the header is generated is causing the problem - the ActivityId and Action elements in the header as well as what WCF is doing with the namespace of the custom header is causing issues. I've successfully consumed the WSDL with wsdl.exe, but WCF seems to be manipulating the header in a way that the Java web service doesn't like. Is there any way I can set up the bindings for the WCF client to not send the ActivityId and Action elements?


回答1:


Do you have tracing turned on in the client? I think that is what is adding the activity ID as its trying to flow the tracing activity to the service for end to end tracing. Turn off the activity tracing flag and it should go - see my comment for the action header




回答2:


This issue commonly occurs when a WCF client attempts to connect to a non-WCF server, e.g. JAX-WS, Websphere etc.

Just to add to Richard's lifesaver answer and address @irperez's comment, the actual settings which need to be disabled to prevent WCF diagnostics from adding ActivityId during WCF Diagnostic Tracing are to remove:

  • Remove ActivityTracing from switchvalue
  • Set propagateActivity to false

i.e. Change

<system.diagnostics>
  <sources>
    <source name="System.ServiceModel" switchValue="Information, ActivityTracing"
            propagateActivity="true">
    <listeners>
      <add name="xml"/>
    </listeners>
  </source>
...

To:

<source name="System.ServiceModel" switchValue="Information" 
        propagateActivity="false">
  <listeners>
    <add name="xml"/>
  </listeners>

If the ActivityId is enabled, it injects the below into the SOAP headers, which can break unsuspecting servers:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header>
    <ActivityId CorrelationId="5de75017-da08-4ac2-84f2-5374953cc2a1" 
         xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">
      9f076849-e76e-4675-84c1-5026b1c2eb1a
    </ActivityId>
  </s:Header>


来源:https://stackoverflow.com/questions/9004244/remove-activityid-from-wcf-request

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!