Reputation: 343
I have created service references in Visual Studio 2017
from WSDL
's provided by our client. One of them requires an attribute/parameter like:
<Item ActionCode="02">
I'm new to SOAP services and can't figure out how to add the ActionCode. I see it in the object browser and in the References.cs.
Here is my code so far (which works for a similar call with no attribute):
BYDUpdateTimeSvc.EmployeeTimeCreateRequestMessage_sync req = new BYDUpdateTimeSvc.EmployeeTimeCreateRequestMessage_sync()
{
BasicMessageHeader = new BYDUpdateTimeSvc.BusinessDocumentBasicMessageHeader(),
EmployeeTime = new BYDUpdateTimeSvc.EmployeeTimeCreateRequest()
{
EmployeeTimeAgreementItemUUID = new BYDUpdateTimeSvc.UUID { Value = rec.employeeTimeAgreement },
Item = new BYDUpdateTimeSvc.EmployeeTimeCreateRequestItem[1]
{
new BYDUpdateTimeSvc.EmployeeTimeCreateRequestItem()
{
TypeCode = activityCode,
PaymentTypeCode = locationCode,
EmployeeTimeValidity = _dateValidity
}
}
}
};
How do I add that parameter/attribute?
Upvotes: 1
Views: 391
Reputation: 1972
I don't know anything about the API you are using. That said, have you tried setting the property using object initializer syntax.
BYDUpdateTimeSvc.EmployeeTimeCreateRequestMessage_sync req = new BYDUpdateTimeSvc.EmployeeTimeCreateRequestMessage_sync()
{
BasicMessageHeader = new BYDUpdateTimeSvc.BusinessDocumentBasicMessageHeader(),
EmployeeTime = new BYDUpdateTimeSvc.EmployeeTimeCreateRequest()
{
EmployeeTimeAgreementItemUUID = new BYDUpdateTimeSvc.UUID { Value = rec.employeeTimeAgreement },
Item = new BYDUpdateTimeSvc.EmployeeTimeCreateRequestItem[1]
{
new BYDUpdateTimeSvc.EmployeeTimeCreateRequestItem()
{
TypeCode = activityCode,
PaymentTypeCode = locationCode,
EmployeeTimeValidity = _dateValidity
}, // added comma
ActionCode = "02"; // set action code here
}
}
};
Upvotes: 2