颤振中的肥皂请求
我正在尝试向 http://www.dneonline.com/calculator.asmx 在 flutter 中添加 2 个数字
ElevatedButton(
onPressed: () async {
var request="""
<?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>
<Add xmlns="http://tempuri.org/">
<intA>1</intA>
<intB>2</intB>
</Add>
</soap:Body>
</soap:Envelope>
""";
http.Response response =
await http.post(
Uri.parse('http://www.dneonline.com/calculator.asmx'),
headers: {
"Content-Type": "text/xml; charset=utf-8",
"Host": "www.dneonline.com",
"Content-Length": request.length.toString(),
"SOAPAction": "http://tempuri.org/Add"
},
body: request
);
print(response.body);
},
child: new Text("Calculate"),
)
但我收到错误
Error: XMLHttpRequest 错误。
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 910:28 get current
包/http/src/browser_client.dart 69:22
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/zone.dart 1685:54 runUnary
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 159:18 handleValue
C:/b/s/w/ir/cache/builder /src/out/host_debug/dart-sdk/lib/async/future_impl.dart 766:44 handleValueCallback
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 795:13 _propagateToListeners C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 592:7 [_complete]
C:/b/s/w/ir/cache /builder/src/out/host_debug/dart-sdk/lib/async/stream_pipe.dart 61:11 _cancelAndValue
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/stream.dart 1288:7
C:/b/s/w/ir/cache/builder/ src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 334:14 _checkAndCall
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 339:39 dcall
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/html/dart2js/html_dart2js.dart 37301:58
at Object.createErrorWithStack (http://localhost:65501/dart_sdk.js:5080:12)
at Function._throw (http://localhost:65501/dart_sdk.js:20337:18)
at Function.throwWithStackTrace (http://localhost:65501/dart_sdk.js:20334:18)
at async._AsyncCallbackEntry.new.callback (http://localhost:65501/dart_sdk.js:40851:18)
at Object._microtaskLoop (http://localhost:65501/dart_sdk.js:40708:13)
at _startMicrotaskLoop (http://localhost:65501/dart_sdk.js:40714:13)
at http://localhost:65501/dart_sdk.js:36191:9
我正在使用和 android studio
http: ^0.13.4
xml :^5.3.1
任何人请帮忙
编辑:
更新
我正在尝试在网络上并遇到cors问题。 现在我在 android 中尝试,得到 400 StatusCode
SoapUI OUTPUT
< a href="https://i.sstatic.net/kkNJ8.png" rel="nofollow noreferrer">soapui
I am trying to send a soap request to http://www.dneonline.com/calculator.asmx in flutter to add 2 number
ElevatedButton(
onPressed: () async {
var request="""
<?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>
<Add xmlns="http://tempuri.org/">
<intA>1</intA>
<intB>2</intB>
</Add>
</soap:Body>
</soap:Envelope>
""";
http.Response response =
await http.post(
Uri.parse('http://www.dneonline.com/calculator.asmx'),
headers: {
"Content-Type": "text/xml; charset=utf-8",
"Host": "www.dneonline.com",
"Content-Length": request.length.toString(),
"SOAPAction": "http://tempuri.org/Add"
},
body: request
);
print(response.body);
},
child: new Text("Calculate"),
)
But I am getting an error
Error: XMLHttpRequest error.
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 910:28 get current
packages/http/src/browser_client.dart 69:22
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/zone.dart 1685:54 runUnary
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 159:18 handleValue
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 766:44 handleValueCallback
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 795:13 _propagateToListeners
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 592:7 [_complete]
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/stream_pipe.dart 61:11 _cancelAndValue
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/stream.dart 1288:7
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 334:14 _checkAndCall
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 339:39 dcall
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/html/dart2js/html_dart2js.dart 37301:58
at Object.createErrorWithStack (http://localhost:65501/dart_sdk.js:5080:12)
at Function._throw (http://localhost:65501/dart_sdk.js:20337:18)
at Function.throwWithStackTrace (http://localhost:65501/dart_sdk.js:20334:18)
at async._AsyncCallbackEntry.new.callback (http://localhost:65501/dart_sdk.js:40851:18)
at Object._microtaskLoop (http://localhost:65501/dart_sdk.js:40708:13)
at _startMicrotaskLoop (http://localhost:65501/dart_sdk.js:40714:13)
at http://localhost:65501/dart_sdk.js:36191:9
I am using and android studio
http: ^0.13.4
xml: ^5.3.1
Anyone please help
Edit:
Update
I was trying in web and was getting cors issue.
Now I am trying in android and I am getting an 400 StatusCode
SoapUI OUTPUT
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这里你可以检查这个。它对我有用
这是回应:
here you can check this. its working for me
And here is response :