2011-06-02 4 views
1

Я установил мой клиент WCF, чтобы пройти через прокси-сервер Fiddler, чтобы я мог захватывать и анализировать трафик. Оказывается, мой WCF-клиент не отправляет все параметры, которые я инициализировал.WCF не отправляет все данные

Некоторые параметры, которые я инициализировал, не отправляются. Одним из примеров и очень важным для меня является lineOfBusiness в массиве lineOfBusinessList.

Я разделил следующий код на 3 раздела, мой WCF-клиент, сообщение о мыле, которое перехватил Fiddler, и сообщение о мыле, которое я ожидаю отправить клиенту WCF.

Мои WCF Клиент

class Program 
    { 
     static void Main(string[] args) 
     { 

      GetProductAvailability(); 
     } 

     public static void GetProductAvailability() 
     { 
      ProductAvailabilityResponseType response; 
      using (ProductAvailabilityServicePortTypeClient client = new ProductAvailabilityServicePortTypeClient("ProductAvailabilityServicePortQSPort")) 
      { 
       client.ClientCredentials.UserName.UserName = "username"; 
       client.ClientCredentials.UserName.Password = "password"; 
       ProductAvailabilityRequestType request = new ProductAvailabilityRequestType 
       { 
        requestHeader = GetRequestHeader(), 
        serviceAddress = GetServiceAddress(), 
        responseFilterCriteria = GetFilterCriteria() 
       }; 

       response = client.getProductAvailability(request); 
      } 

      if (response != null) 
      { 

      } 
      //return null; 
     } 

     private static RequestHeaderType GetRequestHeader() 
     { 
      return new RequestHeaderType 
      { 
       customerInteractionType = ChannelType.WebSelfServe, 
       serviceRequestUserId = "55555", //not sure, ask stevenson 
       serviceConsumer = ServiceConsumerToolType.Emily, 
       serviceRequestTimestamp = DateTime.Now, 
       language = LanguageType.English, 
       referenceID = "A24T34H3" //ask stevenson if this is necessary 
      }; 
     } 

     private static ServiceAddressSearchType GetServiceAddress() 
     { 
      return new ServiceAddressSearchType 
      { 
       addressID = "000622060", 
       address = new AddressType 
       { 
        provinceOrState = new ProvinceOrStateType { type = ProvinceOrStateValueType.ON } 
       } 
      }; 
     } 
     private static ProductAvailabilityFilterType GetFilterCriteria() 
     { 
      return new ProductAvailabilityFilterType 
      { 
       serviceSupportInfoOnly = false, 
       customerSegment = CustomerSegmentType.Residential, 
       channelList = new ChannelType[1] { ChannelType.WebSelfServe }, 
       lineOfBusinessList = new LineOfBusinessProductType[1] { 
        new LineOfBusinessProductType{ lineOfBusiness = LineOfBusinessType.Internet } 
       }, 
       oneBillOffers = false, 
       satelliteTechnicianRequired = false, 
      }; 
     } 
    } 

Что на самом деле отправляется:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 
    <s:Header> 
    <ActivityId CorrelationId="ab64c2a1-7e32-448c-8d64-80fead66e566" xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">cb08f434-ec5e-409e-a550-a0826739aa94</ActivityId> 
    </s:Header> 
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    <getProductAvailability xmlns="ca/bell/oms/autotype/productavailability"> 
     <requestHeader> 
     <customerInteractionType xmlns="ca/bell/oms/autotype/omscommonrequest">WebSelfServe</customerInteractionType> 
     <serviceRequestUserId xmlns="ca/bell/oms/autotype/omscommonrequest">55555</serviceRequestUserId> 
     <serviceConsumer xmlns="ca/bell/oms/autotype/omscommonrequest">Emily</serviceConsumer> 
     <serviceRequestTimestamp xmlns="ca/bell/oms/autotype/omscommonrequest">2011-06-02T16:26:13.4639736-04:00</serviceRequestTimestamp> 
     <language xmlns="ca/bell/oms/autotype/omscommonrequest">English</language> 
     <referenceID xmlns="ca/bell/oms/autotype/omscommonrequest">A24T34H3</referenceID> 
     </requestHeader> 
     <serviceAddress> 
     <addressID>000622060</addressID> 
     <address> 
      <provinceOrState xmlns="ca/bell/oms/autotype/omscommon"/> 
     </address> 
     </serviceAddress> 
     <responseFilterCriteria> 
     <serviceSupportInfoOnly>false</serviceSupportInfoOnly> 
     <channelList> 
      <channel>WebSelfServe</channel> 
     </channelList> 
     <lineOfBusinessList> 
      <lineOfBusinessProduct/> 
     </lineOfBusinessList> 
     </responseFilterCriteria> 
    </getProductAvailability> 
    </s:Body> 
</s:Envelope> 

SOAP-messasge Я ожидаю, что мой WCF клиент для отправки:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:prod="ca/bell/oms/autotype/productavailability" xmlns:oms="ca/bell/oms/autotype/omscommonrequest" xmlns:oms1="ca/bell/oms/autotype/omscommon"> 
    <soapenv:Header/> 
    <soapenv:Body> 
     <prod:getProductAvailability> 
      <oms:requestHeader> 
       <oms:customerInteractionType xmlns:n2 = "ca/bell/oms/autotype/omscommonrequest">WebSelfServe</oms:customerInteractionType> 
       <oms:serviceRequestUserId xmlns:n3 = "ca/bell/oms/autotype/omscommonrequest">55555</oms:serviceRequestUserId> 
       <oms:serviceConsumer xmlns:n4 = "ca/bell/oms/autotype/omscommonrequest">Emily</oms:serviceConsumer> 
       <oms:serviceRequestTimestamp xmlns:n5 = "ca/bell/oms/autotype/omscommonrequest">2010-11-30T11:27:08.431-05:00</oms:serviceRequestTimestamp> 
       <oms:language xmlns:n6 = "ca/bell/oms/autotype/omscommonrequest">English</oms:language> 
       <oms:referenceID xmlns:n7 = "ca/bell/oms/autotype/omscommonrequest"></oms:referenceID> 
      </oms:requestHeader> 
     <prod:serviceAddress> 
      <prod:addressID>000622060</prod:addressID> 
      <prod:address> 
       <oms1:provinceOrState> 
        <oms1:type>ON</oms1:type> 
       </oms1:provinceOrState> 
      </prod:address> 
     </prod:serviceAddress> 
     <prod:responseFilterCriteria> 
      <prod:serviceSupportInfoOnly>false</prod:serviceSupportInfoOnly> 
      <prod:customerSegment>Residential</prod:customerSegment> 
      <prod:channelList> 
       <prod:channel>WebSelfServe</prod:channel> 
      </prod:channelList> 
      <prod:lineOfBusinessList> 
       <prod:lineOfBusinessProduct> 
        <prod:lineOfBusiness>Internet</prod:lineOfBusiness> 
       </prod:lineOfBusinessProduct> 
      </prod:lineOfBusinessList> 
      <prod:oneBillOffers>false</prod:oneBillOffers> 
     <prod:satelliteTechnicianRequired>false</prod:satelliteTechnicianRequired> 
     </prod:responseFilterCriteria> 
     </prod:getProductAvailability> 
    </soapenv:Body> 
</soapenv:Envelope> 
+0

Можете ли вы опубликовать определения контрактов, используемые в этой проблеме? – carlosfigueira

+0

Да, пожалуйста, поделитесь своими контрактами с данными. –

+0

Я не хочу давать контракт с данными, потому что это связано с выявлением личности моего клиента/компании, и я не чувствую себя комфортно. – burnt1ce

ответ

0

Угадайте, у вас отсутствует атрибут DataMember для некоторых ваших свойств DataContract.

Смежные вопросы