我的web服务得到ResponseCode: 400(错误的请求)



我已经尝试比较,使用代理邮递员和肥皂测试或我能做的一切。但是我没有发现Post方法的任何错误。它只是我收到了坏请求。

下面是我需要遵循的示例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>

我发送的post方法来自flutter。有什么我没注意到的,或者你们能建议我做什么吗?

对于listInspCi,我从

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

经过一番思考,我设法找到了一种避免Bad Request错误的方法。注意我在Flutter中所做的 需要解码到数据表c# Webservice Api.

Flutter:我所做的是在将数据传递给webservice之前先在<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));

相关内容

  • 没有找到相关文章

最新更新