There is a (SOAP) webservice that I am calling. If I use SOAP-UI tool with the same values, it works good. However, when I call through C# code, it is giving me this error. I do not have a proper brought up in ASP .Net world.
if ( serviceFee > 0 )
{
surchargeItemsReq SurchargeItemsReqObject = new attachSurchargeItemsRequest()
{
aID = this._applicationId,
tID = token,
provSurcharge = ((decimal)1.8)
};
try
{
this.WriteLog("Invoking Webservice SurchargeItems with ServiceFee");
surchargeItemsResponse SurchargeItemsRespObject = ws.surchargeItems(SurchargeItemsReqObject);
}
The decimal variable had 1.8 as value in it. When I was using the variable itself, I get the same issue. So I literally put (decimal)1.8 in there. Same issue. Please note that in SoapUI tool, request with same values literally put in, works good.
Exception I am getting is this.
System.Web.Services.Protocols.SoapHeaderException was caught
HResult=-2146233087
Message=provSurcharge size is invalid
Source=System.Web.Services
StackTrace:
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at com.sac.commerce.providers.KanPayService.ServerPaymentPortalService.surchargeItems(surchargeItemsRequest
InnerException:
Here is the request object (in visual studio generated code)
public partial class surchargeItemsReq {
private decimal provSurchargeField;
private bool provSurchargeFieldSpecified;
public decimal provSurcharge {
get {
return this.provSurchargeField;
}
set {
this.provSurchargeField = value;
}
}
@HansKilian commented saying to set the provSurchargeSpecified boolean flag value. After setting it to true, it worked. Who would have thought this?
if ( serviceFee > 0 )
{
surchargeItemsRequest SurchargeItemsReqObject =
new surchargeItemsRequest()
{
provSurcharge = serviceFee,
provSurchargeSpecified = true
};
I wonder why for only some fields (bool or decimal types) have this extra boolean fieldspecified property code-generated. At first I thought I could find something in the WSDL-XSD. There are other minOccurs="0" type fields too that do not have this kind of code generated.
<xs:element minOccurs="0" name="provSurcharge" type="xs:decimal"/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.