Web Services 我的Web服务获得响应代码:400(错误请求)

4ktjp1zp  于 2022-12-04  发布在  其他
关注(0)|答案(1)|浏览(420)

我已经尝试比较,使用代理 Postman 和肥皂测试或一切我可以做的。但我没有发现任何错误,我的后方法。它只是我得到坏的请求。
下面是我需要遵循的示例SOAP 1.1请求。

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <Save_Progress xmlns="http://smart-mobile-test.bo/">
      <UserID>string</UserID>
      <isNewInsp>string</isNewInsp>
      <InspID>long</InspID>
      <intcsRevID>int</intcsRevID>
      <numSampleSizes>string</numSampleSizes>
      <InspRevID>long</InspRevID>
      <listInspCi>string</listInspCi>
      <methodName>string</methodName>
      <StartTime>string</StartTime>
      <EndTime>string</EndTime>
    </Save_Progress>
  </soap:Body>
</soap:Envelope>

以下是我发送的内容:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <Save_Progress xmlns="http://smart-mobile-test.bo/" >
      Save_Progress<UserID>1</UserID>
      <isNewInsp>true</isNewInsp>
      <InspID>0</InspID>
      <intcsRevID>10048</intcsRevID>
      <numSampleSizes>2</numSampleSizes>
      <InspRevID>0</InspRevID>
      <listInspCi>[{"CIRevID":"11084","CIID":"277","Check Item No":"1","Check Item Name":"TS-1","Feature!":"","Data Type":"1","Tool":"IM SERIES 2Q-62037","Sample Size!":"0","LSL":"232.80","Target":"233.00","USL":"233.20","LCL":"","CL":"","UCL":"","RLCL!":"","RCL!":"","RUCL!":"","UoM!":"mm","Insp. Rank!":"","Insp. Level!":"","CTQ!":"","Side!":"","Position!":"","Image":"","WI":"","Specification":"233.00","Code":"0","GD&T Symbol!":"","Operation!":"","+Tol":"0.20","-Tol":"-0.20","CIRemark3!":"","CIRemark4!":"233.00","CIRemark5!":"","CIRemark6!":"","CIRemark 7!":"","CIRemark 8!":"","Data 1":"","Data 2":"","Result1!":"0","Result2!":"0"},{"CIRevID":"11085","CIID":"278","Check Item No":"2","Check Item Name":"TS-2","Feature!":"","Data Type":"1","Tool":"IM SERIES 2Q-62037","Sample Size!":"0","LSL":"125.85","Target":"126.00","USL":"126.15","LCL":"","CL":"","UCL":"","RLCL!":"","RCL!":"","RUCL!":"","UoM!":"mm","Insp. Rank!":"","Insp. Level!":"","CTQ!":"","Side!":"","Position!":"","Image":"","WI":"","Specification":"126.00","Code":"0","GD&T Symbol!":"","Operation!":"","+Tol":"0.15","-Tol":"-0.15","CIRemark3!":"","CIRemark4!":"126.00","CIRemark5!":"","CIRemark6!":"","CIRemark 7!":"","CIRemark 8!":"","Data 1":"","Data 2":"","Result1!":"0","Result2!":"0"},{"CIRevID":"11086","CIID":"279","Check Item No":"3","Check Item Name":"TS-3","Feature!":"","Data Type":"1","Tool":"IM SERIES 2Q-62037","Sample Size!":"0","LSL":"148.65","Target":"148.80","USL":"148.95","LCL":"","CL":"","UCL":"","RLCL!":"","RCL!":"","RUCL!":"","UoM!":"mm","Insp. Rank!":"","Insp. Level!":"","CTQ!":"","Side!":"","Position!":"","Image":"","WI":"","Specification":"148.80","Code":"0","GD&T Symbol!":"","Operation!":"","+Tol":"0.15","-Tol":"-0.15","CIRemark3!":"","CIRemark4!":"148.80","CIRemark5!":"","CIRemark6!":"","CIRemark 7!":"","CIRemark 8!":"","Data 1":"","Data 2":"","Result1!":"0","Result2!":"0"},{"CIRevID":"11087","CIID":"280","Check Item No":"4","Check Item Name":"TS-4","Feature!":"","Data Type":"1","Tool":"IM SERIES 2Q-62037","Sample Size!":"0","LSL":"41.20","Target":"41.30","USL":"41.40","LCL":"","CL":"","UCL":"","RLCL!":"","RCL!":"","RUCL!":"","UoM!":"mm","Insp. Rank!":"","Insp. Level!":"","CTQ!":"","Side!":"","Position!":"","Image":"","WI":"","Specification":"41.30","Code":"0","GD&T Symbol!":"","Operation!":"","+Tol":"0.10","-Tol":"-0.10","CIRemark3!":"","CIRemark4!":"41.30","CIRemark5!":"","CIRemark6!":"","CIRemark 7!":"","CIRemark 8!":"","Data 1":"","Data 2":"","Result1!":"0","Result2!":"0"},{"CIRevID":"11088","CIID":"281","Check Item No":"5","Check Item Name":"TS-5","Feature!":"","Data Type":"1","Tool":"Micrometer 2Q-32008","Sample Size!":"0","LSL":"1.16","Target":"1.30","USL":"1.44","LCL":"","CL":"","UCL":"","RLCL!":"","RCL!":"","RUCL!":"","UoM!":"mm","Insp. Rank!":"","Insp. Level!":"","CTQ!":"","Side!":"","Position!":"","Image":"","WI":"","Specification":"1.30","Code":"0","GD&T Symbol!":"","Operation!":"","+Tol":"0.14","-Tol":"-0.14","CIRemark3!":"","CIRemark4!":"1.30","CIRemark5!":"","CIRemark6!":"","CIRemark 7!":"","CIRemark 8!":"","Data 1":"","Data 2":"","Result1!":"","Result2!":""},{"CIRevID":"11089","CIID":"282","Check Item No":"6","Check Item Name":"Hole-Position","Feature!":"","Data Type":"3","Tool":"Visual","Sample Size!":"0","LSL":"","Target":"","USL":"","LCL":"","CL":"","UCL":"","RLCL!":"","RCL!":"","RUCL!":"","UoM!":"","Insp. Rank!":"","Insp. Level!":"","CTQ!":"","Side!":"","Position!":"","Image":"","WI":"","Specification":"","Code":"0","GD&T Symbol!":"","Operation!":"","+Tol":"","-Tol":"","CIRemark3!":"","CIRemark4!":"","CIRemark5!":"Yes","CIRemark6!":"","CIRemark 7!":"","CIRemark 8!":"","Data 1":"","Data 2":"","Result1!":"","Result2!":""},{"CIRevID":"11090","CIID":"283","Check Item No":"7","Check Item Name":"Burr","Feature!":"","Data Type":"3","Tool":"Visual","Sample Size!":"0","LSL":"","Target":"","USL":"","LCL":"","CL":"","UCL":"","RLCL!":"","RCL!":"","RUCL!":"","UoM!":"","Insp. Rank!":"","Insp. Level!":"","CTQ!":"","Side!":"","Position!":"","Image":"","WI":"","Specification":"","Code":"0","GD&T Symbol!":"","Operation!":"","+Tol":"","-Tol":"","CIRemark3!":"","CIRemark4!":"","CIRemark5!":"Yes","CIRemark6!":"","CIRemark 7!":"","CIRemark 8!":"","Data 1":"","Data 2":"","Result1!":"","Result2!":""},{"CIRevID":"11091","CIID":"284","Check Item No":"8","Check Item Name":"Solder Resist Position Deviation","Feature!":"","Data Type":"3","Tool":"Visual","Sample Size!":"0","LSL":"","Target":"","USL":"","LCL":"","CL":"","UCL":"","RLCL!":"","RCL!":"","RUCL!":"","UoM!":"","Insp. Rank!":"","Insp. Level!":"","CTQ!":"","Side!":"","Position!":"","Image":"","WI":"","Specification":"","Code":"0","GD&T Symbol!":"","Operation!":"","+Tol":"","-Tol":"","CIRemark3!":"","CIRemark4!":"","CIRemark5!":"Yes","CIRemark6!":"","CIRemark 7!":"","CIRemark 8!":"","Data 1":"","Data 2":"","Result1!":"","Result2!":""},{"CIRevID":"11092","CIID":"285","Check Item No":"9","Check Item Name":"Crack","Feature!":"","Data Type":"3","Tool":"Visual","Sample Size!":"0","LSL":"","Target":"","USL":"","LCL":"","CL":"","UCL":"","RLCL!":"","RCL!":"","RUCL!":"","UoM!":"","Insp. Rank!":"","Insp. Level!":"","CTQ!":"","Side!":"","Position!":"","Image":"","WI":"","Specification":"","Code":"0","GD&T Symbol!":"","Operation!":"","+Tol":"","-Tol":"","CIRemark3!":"","CIRemark4!":"","CIRemark5!":"Yes","CIRemark6!":"","CIRemark 7!":"","CIRemark 8!":"","Data 1":"","Data 2":"","Result1!":"","Result2!":""},{"CIRevID":"11093","CIID":"286","Check Item No":"10","Check Item Name":"Bent","Feature!":"","Data Type":"3","Tool":"Visual","Sample Size!":"0","LSL":"","Target":"","USL":"","LCL":"","CL":"","UCL":"","RLCL!":"","RCL!":"","RUCL!":"","UoM!":"","Insp. Rank!":"","Insp. Level!":"","CTQ!":"","Side!":"","Position!":"","Image":"","WI":"","Specification":"","Code":"0","GD&T Symbol!":"","Operation!":"","+Tol":"","-Tol":"","CIRemark3!":"","CIRemark4!":"","CIRemark5!":"Yes","CIRemark6!":"","CIRemark 7!":"","CIRemark 8!":"","Data 1":"","Data 2":"","Result1!":"","Result2!":""},{"CIRevID":"11094","CIID":"287","Check Item No":"11","Check Item Name":"Dimension","Feature!":"Supplier Outgoing Inspection Data","Data Type":"3","Tool":"Visual","Sample Size!":"0","LSL":"","Target":"","USL":"","LCL":"","CL":"","UCL":"","RLCL!":"","RCL!":"","RUCL!":"","UoM!":"","Insp. Rank!":"","Insp. Level!":"","CTQ!":"","Side!":"","Position!":"","Image":"","WI":"","Specification":"","Code":"0","GD&T Symbol!":"","Operation!":"","+Tol":"","-Tol":"","CIRemark3!":"","CIRemark4!":"","CIRemark5!":"Yes","CIRemark6!":"","CIRemark 7!":"","CIRemark 8!":"","Data 1":"","Data 2":"","Result1!":"","Result2!":""}]</listInspCi>
      <methodName>IM SERIES 2Q-62037</methodName>
      <StartTime>2022-11-24 08:41:47.557904</StartTime>
      <EndTime>2022-11-24 08:42:27.753563</EndTime>
      
    </Save_Progress>
  </soap:Body>
</soap:Envelope>

我发的帖子是来自flutter的,有什么我遗漏的或者你们有什么可以建议我做的吗?
对于我从

List<Map<String, dynamic>> inspci = [*list*];
String listInspCI = jsonEncode(inspCI);
wb1gzix0

wb1gzix01#

经过一些思考,我设法找到了一种避免Bad Request错误的方法。注意,我在Flutter中所做的是Map〈String,dynamic〉需要在C# Webservice Api中解码为datatable
Flutter:我所做的是在将数据传递给Web服务之前,首先在<listInspCi>上进行UTF8编码。

Map<String, dynamic> inspCI = --some data-- ;
  List<int> EncodedlistInspCI = utf8.encode(json.encode(inspCI));
  String listInspCI = jsonEncode(EncodedlistInspCI);

C#:然后我用类似这样的东西再次解码。

utf8 = new UTF8Encoding();
int[] intList = JsonConvert.DeserializeObject<int[]>(listInspCi);
Byte[] byteList = Array.ConvertAll<int, byte>(intList, Convert.ToByte);
dtInsp = JsonConvert.DeserializeObject<DataTable>(utf8.GetString(byteList));

相关问题