开发者

WCF: One property of another object type in Request object becomes NULL

I have WCF service with both ws & basic bindings. From .Net client things work fine but when I call the same method from Java client the critera property in request object comes as NULL though from the wireshark I can see the data is coming. For .Net it uses GET coming from a webpage but for Java it uses POST. Not only this if I go to RequestMessage in OperationContext I can see the xml.

REQUEST MESSAGE FROM .NET Client:

RequestMessage  {<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header>
    <To s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://mcac83101cj.us.maritz.net/CouponService/CouponService.svc</To>
    <Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://tempuri.org/ICouponService/GetOrderByOrderId</Action>
  </s:Header>
  <s:Body>
    <GetOrderByOrderId xmlns="http://tempuri.org/">
      <orderRequest xmlns:a="http://schemas.datacontract.org/2004/07/CLinkService.Messages" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
        <AccessToken xmlns="http://schemas.datacontract.org/2004/07/CLinkService.MessageBase">c2bf6e1e-e6fd-4930-8a9e-da9d918bbdc4</AccessToken>
        <Action xmlns="http://schemas.datacontract.org/2004/07/CLinkService.MessageBase">Read</Action>
        <ClientTag xmlns="http://schemas.datacontract.org/2004/07/CLinkService.MessageBase">Maritz@$0</ClientTag>
        <LoadOptions i:nil="true" xmlns="http://schemas.datacontract.org/2004/07/CLinkService.MessageBase" xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />
        <RequestId xmlns="http://schemas.datacontract.org/2004/07/CLinkService.MessageBase">93358933-7965-442f-bf38-9946ecfb3213</RequestId>
        <Version i:nil="true" xmlns="http://schemas.datacontract.org/2004/07/CLinkService.MessageBase" />
        <a:Criteria xmlns:b="http://schemas.datacontract.org/2004/07/CLinkService.Criteria">
          <b:DealerCode i:nil="true" />
          <b:Language i:nil="true" />
          <b:SortExpression i:nil="true" />
          <b:UserName i:nil="true" />
          <b:Xslt>MPS</b:Xslt>
          <b:OrderId>11</b:OrderId>
        </a:Criteria>
        <a:Order i:nil="true" xmlns:b="http://schemas.datacontract.org/2004/07/CLinkService.Dto" />
      </orderRequest>
    </GetOrderByOrderId>
  </s:Body>
</s:Envelope>}  System.ServiceModel.Channels.Message {System.ServiceModel.Channels.BufferedMessage}

REQUEST MESSAGE FROM JAVA CLIENT:

RequestMessage  {<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <To s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://mcac83101cj.us.maritz.net/CouponService/CouponService.svc</To>
    <Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://tempuri.org/ICouponService/GetOrderByOrderId</Action>
  </s:Header>
  <S:Body>
    <ns6:GetOrderByOrderId 
    xmlns:ns7="http://schemas.microsoft.com/2003/10/Serialization/" 
    xmlns:ns6="http://tempuri.org/" 
    xmlns:ns5="http://schemas.datacontract.org/2004/07/CLinkService.Dto" 
    xmlns:ns4="http://schemas.datacontract.org/2004/07/CLinkService.Messages" 
    xmlns:ns3="http://schemas.datacontract.org/2004/07/CLinkService.Criteria" 
    xmlns:ns2="http://schemas.microsoft.com/2003/10/Serialization/Arrays" 
    xmlns="http://schemas.datacontract.org/2004/07/CLinkService.MessageBase">
      <ns6:orderRequest>
        <Action>Read</Action>
        <ClientTag>Maritz@$0</ClientTag>
        <RequestId>200</RequestId>
        <ns3:OrderCriteria>
          <ns3:DealerCode>B0000</ns3:DealerCode>
          <ns3:Language>FR</ns3:Language>
          <ns3:Xslt>MPS</ns3:Xslt>
          <ns3:OrderId>9</ns3:OrderId>
        </ns3:OrderCriteria>
        <ns5:OrderDto>
          <ns5:DealerCode>B0000</ns5:DealerCode>
          <ns5:Language>FR</ns5:Language>
          <ns5:OrderId>11</ns5:OrderId>
        </ns5:OrderDto>
      </ns6:orderRequest>
    </ns6:GetOrderByOrderId>
  </S:Body>
</S:Envelope>}  System.ServiceModel.Channels.Message {System.ServiceModel.Channels.BufferedMessage}

Web.Config for server is as below:

  <system.serviceModel>
    <services>
      <service behaviorConfiguration="CLinkService.CouponServiceBehavior" name="CLinkService.ServiceImplementations.CouponService">
        <endpoint name="wsHttpBinding" address="secure" binding="wsHttpBinding" bindingConfiguration="wsBindingAction" contract="CLinkService.ServiceContracts.ICouponService">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint name="basicHttpBinding" address="" binding="basicHttpBinding" bindingConfiguration="basicBindingAction" contract="CLinkService.ServiceContracts.ICouponService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="CLinkService.CouponServiceBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <wsHttpBinding>
        <binding name="wsBindingAction" transactionFlow="false" sendTimeout="00:30:00" receiveTimeout="00:30:00" maxReceivedMessageSize="524288" maxBufferPoolSize="524288">
          <reliableSession enabled="true"/>
          <security mode="None">
          </security>
        </binding>
      </wsHttpBinding>
      <basicHttpBinding>
        <binding name="basicBindingAction" sendTimeout="00:30:00" receiveTimeout="00:30:00" maxReceivedMessageSize="524288" maxBufferPoolSize="524288">
          <security mode="None">
          </security>
        </b开发者_如何学JAVAinding>
      </basicHttpBinding>
    </bindings>
  </system.serviceModel>


Your .NET client is probably emitting a default value for a:Criteria. You can suppress this behavior by annotating your DataMember with EmitDefaultValue = false:-

[DataMember(EmitDefaultValue = false)]

Have a look at this MSDN article as well:- http://msdn.microsoft.com/en-us/library/aa347792.aspx


No this is not the case. When we the client calls GetOrderByOrderId & pass the request object then the client is setting the criteria which is of type OrderCriteria & if you look at the OperationContext RequestMessage I mentioned above I can see the parameters are set but somehow WCF is not able to deserialize the Criteria property of OrderRequest object & hence it becomes NULL in case of POST method from Java client & not for .Net client which is GET method if use sniffer tool to check details

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜