我收到了以下异常:
抛出异常:'System.ServiceModel.ProtocolException' mscorlib.dll响应消息的内容类型text / xml 不匹配绑定的内容类型(multipart / related; 类型= “应用/ XOP + xml” 的)。如果使用自定义编码器,请确保 IsContentTypeSupported方法正确实现。首先 响应的330个字节是:'2018-01-22 4时53分02秒
2
RequestError1SeriousError00'
我不确定如何解决它。
以下是我的网络配置中的系统服务模型:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="BulkDataExchangeService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00"
sendTimeout="00:01:00" bypassProxyOnLocal="false"
transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Mtom" textEncoding="utf-8"
useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192"
maxArrayLength="16384" maxBytesPerRead="4096"
maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="Certificate" algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://api.sandbox.ebay.com/ws/api.dll"
binding="wsHttpBinding" bindingConfiguration="BulkDataExchangeService"
contract="BulkDataExchangeServicePort" name="BulkDataExchangeService">
<identity>
<userPrincipalName value="machine\user" />
</identity>
</endpoint>
</client>
</system.serviceModel>
这是我用来尝试创建上传作业的代码:
private void CreateUploadJobEbay()
{
var ebayAuthTokenSetting = _settingService.GetSettingByKey(
"ebaysetting.authtoken", "");
//EndpointAddress endpoint = new EndpointAddress("https://webservices.sandbox.ebay.com/BulkDataExchangeService");
BulkDataExchangeServicePortClient client = new BulkDataExchangeServicePortClient("BulkDataExchangeService");
using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
{
HttpRequestMessageProperty httpRequest = new HttpRequestMessageProperty();
OperationContext.Current.OutgoingMessageProperties.Add(HttpRequestMessageProperty.Name, httpRequest);
//Add the request headers
httpRequest.Headers.Add("X-EBAY-SOA-SECURITY-TOKEN", ebayAuthTokenSetting);
httpRequest.Headers.Add("X-EBAY-SOA-SERVICE-NAME", "BulkDataExchangeService");
httpRequest.Headers.Add("X-EBAY-SOA-SERVICE-VERSION", "1.0.0");
httpRequest.Headers.Add("X-EBAY-SOA-MESSAGE-PROTOCOL", "SOAP12");
httpRequest.Headers.Add("X-EBAY-SOA-OPERATION-NAME", "createUploadJob");
//Create the request
CreateUploadJobRequest req = new CreateUploadJobRequest();
//Supply additional parameters
//The UUID must be unique. Once used, you can't use it again
req.UUID = System.Guid.NewGuid().ToString();
//Specify job type
req.uploadJobType = "ReviseInventoryStatus";
req.fileType = FileType.XML;
req.fileTypeSpecified = true;
//Get the response
CreateUploadJobResponse resp = client.createUploadJob(req);
Debug.WriteLine("code is hitting here >>> ");
Debug.WriteLine("resp = " + resp);
Debug.WriteLine("code is hitting here >>> ");
}
}
这是抛出异常的部分CreateUploadJobResponse resp = client.createUploadJob(req);
更新: 批量数据交换服务代码可以是found here它位于BDXSample.zip文件的底部附近
任何人都知道如何解决这个问题。干杯
答案 0 :(得分:0)
您应该使用BulkDataExchangeServicePortClient("BulkDataExchangeServiceSOAP")
吗? (以SOAP结尾,而您的代码省略了该部分)
此外,我在链接页面中没有看到req.fileTypeSpecified = true;
。也许你不需要那条线。