您好,下面是发生错误的代码“远程服务器返回了意外的响应:(400)错误的请求” 。我不知道我要去哪里错了。将WSDL URL添加到我的解决方案后,我便能够获取所有方法。但是为什么我会收到此错误。
EXOZEndpointPortClient client = new EXOZEndpointPortClient();
client.ClientCredentials.UserName.UserName = username;
client.ClientCredentials.UserName.Password = password;
client.Endpoint.Name = "EXOZEndpointPortSoap12";
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
GetAvailabilityRequest getAvailabilty = new GetAvailabilityRequest();
getAvailabilty.FromDate = System.DateTime.Now; // should be Datetime (ISO 8601)
getAvailabilty.ToDate = System.DateTime.Now.AddDays(7);// should be Datetime (ISO 8601)
getAvailabilty.ProductOptionQuantities = new ProductOptionQuantity[] { new ProductOptionQuantity { id = 1, Value = 39490 } };
var response = client.GetAvailability(getAvailabilty);
下面是我的web.config
<system.serviceModel>
<bindings>
<customBinding>
<binding name="EXOZEndpointPortSoap12">
<textMessageEncoding messageVersion="Soap12" />
<httpsTransport/>
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="https://x.x.net.au/v2/exoz"
binding="customBinding" bindingConfiguration="EXOZEndpointPortSoap12"
contract="TicketsMatesTransactionalAPI.EXOZEndpointPort" name="EXOZEndpointPortSoap12" />
</client>