开发者

WCF not sending all data

I have set up my WCF client to go through a Fiddler proxy so i can capture and analyze traffic. It turns out, my WCF client is not sending all the parameters that i have initialized.

Some of the parameter that i've initialized are not being sent. One being an example and very crucial to me is the lineOfBusiness in the lineOfBusinessList array.

I've divided the following code into 3 sections, my WCF client, the soap message that Fiddler intercepted and the soap message that i expect my WCF client to send.

My WCF Client

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,
            };
        }
    }

What's actually being sent:

<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>

The SOAP messasge I'm expecting my WCF client to send:

<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>
                  <pr开发者_JS百科od: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>


At a guess, you are missing the DataMember attribute on some of your DataContract properties.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜