简体   繁体   English

我的网络服务得到 ResponseCode: 400 (Bad Request)

[英]My webservice got ResponseCode: 400 (Bad Request)

I already try to compare, use agent postman and soap testing or everything I could do.我已经尝试比较,使用代理 postman 和 soap 测试或我能做的一切。 But I do not found any error for my Post method.但是我没有发现我的 Post 方法有任何错误。 It just I get Bad Request.只是我收到了错误的请求。

Here is the sample SOAP 1.1 request that I need to follow.这是我需要遵循的示例 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>

And the following is what I send:以下是我发送的内容:

<?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>

The post method that I send is from flutter. Is there something I miss or are there something you guys can suggest me to do?我发的post方法是flutter发的。有什么我想念的吗,或者你们有什么可以建议我做的吗?

For the listInspCi i get from对于 listInspCi 我从

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

After having some thoughts, I managed to figure out a way to avoid Bad Request error.经过一番思考,我设法找到了一种避免 Bad Request 错误的方法。 Notice that what I done from Flutter is Map<String, dynamic> need to decode to datatable in C# Webservice Api .请注意,我从Flutter所做的是Map<String, dynamic>需要解码为C# Webservice Api中的数据表。

Flutter: What I have done is I do UTF8 Encoding first on <listInspCi> before passing data to webservice. Flutter:我所做的是在将数据传递给 web 服务之前,先在<listInspCi>上进行 UTF8 编码。

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

C#: Then I decode again using something like this. 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));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM