Tempname
Tempname

Reputation: 565

Parameters in complex type missing from Soap Request

I have a very odd bug that I am trying to track down. In my code I am calling a basic web service. The issue that I am seeing certain parameters in a complex type are simply not being set, even when I set them statically.

When debugging the code, I have verified that the properties of the object are correctly set, this issue only happens when I generate the soap request. I am generating the soap request by using the built in web service proxy in .net (Add Webservice Reference in visual studio)

Any help with this is greatly appreciated.

The elements that are not being set in the complex type OrderTransaction are: tracerId orderDate updateTime

Here is an example of what I am seeing:

I statically create the object

orderArray[0] = new OrderTransaction();

I then populate a parameter in this object

orderArray[0].tracerId = 47;

When I call my web service this parameter is completely missing from the complex type.'

Here is an example of my complex type xsd

<xs:complexType name="OrderTransaction">
<xs:sequence>
  <xs:element minOccurs="0" name="cardType" type="xs:string" />
  <xs:element name="ccEncryptedFlag" type="xs:short" />
  <xs:element minOccurs="0" name="chainShortcode" type="xs:string" />
  <xs:element minOccurs="0" name="channelCode" type="xs:string" />
  <xs:element minOccurs="0" name="creditCardNumber" type="xs:string" />
  <xs:element minOccurs="0" name="custIdMigratedToRex" type="xs:dateTime" />
  <xs:element minOccurs="0" name="customerId" type="xs:long" />
  <xs:element minOccurs="0" name="customerName" type="xs:string" />
  <xs:element minOccurs="0" name="expirationMonth" type="xs:string" />
  <xs:element minOccurs="0" name="expirationYear" type="xs:string" />
  <xs:element minOccurs="0" name="orderDate" type="xs:dateTime" />
  <xs:element name="orderId" type="xs:long" />
  <xs:element minOccurs="0" name="provinceCode" type="xs:string" />
  <xs:element name="totalItemTransactions" type="xs:short" />
  <xs:element minOccurs="0" name="tracerId" type="xs:long" />
  <xs:element minOccurs="0" name="updateTime" type="xs:dateTime" />
</xs:sequence>

Here is my current testing code:

ZBatch_PublisherService.ItemTransaction[] itemArray = new ItemTransaction[1];
ZBatch_PublisherService.OrderTransaction[] orderArray = new OrderTransaction[1];
itemArray[0] = new ItemTransaction();
itemArray[0].classId = 1153;
itemArray[0].fulfillmentCenterId = 123;
itemArray[0].fulfillmentType = "TEST";
itemArray[0].lineItemId = 597;
itemArray[0].migratedFlag = 0;
itemArray[0].taxAmount = Convert.ToDecimal("7.00");
itemArray[0].sku = "110853852";
itemArray[0].quantity = 1;
itemArray[0].taxService = "CSS";
itemArray[0].totalShippingAmount = Convert.ToDecimal("5.99");
itemArray[0].tracerId = 47;
itemArray[0].trackingNo = "abc2134";
itemArray[0].unitAmount = Convert.ToDecimal("79.99");
itemArray[0].updateTime = Convert.ToDateTime("2011-10-27T17:47:30");
orderArray[0] = new OrderTransaction();
orderArray[0].tracerId = 47;
orderArray[0].customerId = 15;
orderArray[0].cardType = "VISA";
orderArray[0].ccEncryptedFlag = 3;
orderArray[0].chainShortcode = "ABC";
orderArray[0].creditCardNumber = "1234566788";
orderArray[0].customerName = "John Doe";
orderArray[0].expirationMonth = "APR";
orderArray[0].expirationYear = "2014";
orderArray[0].orderDate = Convert.ToDateTime("2011-10-27T17:47:30");
orderArray[0].orderId = 343;
orderArray[0].provinceCode = "AB";
orderArray[0].totalItemTransactions = 1;
orderArray[0].updateTime = Convert.ToDateTime("2011-10-27T17:47:30");
ZBatch_PublisherService.ZBatchPublisherServiceService ws = new ZBatchPublisherServiceService();
ws.saveBatch(orderArray, itemArray);

Upvotes: 1

Views: 1127

Answers (1)

fdlane
fdlane

Reputation: 105

I had this same issue and found the issue was that some types were not nullable. So to tell whether it is actually null, the C# web service has an extra flag with the variable name with the word 'Specified' appended. i.e. traceIdSpecified = true;

In addition to setting the value of a property, you also have to set the '...Specified' property to true.

This fixed my issue.

hth

fdlane

Upvotes: 4

Related Questions