如何将请求发送到asmx webservice

问题描述 投票:0回答:1

我正在使用qazxsw pi网络服务。但我不知道如何发送请求。我的网络服务:

asmx

我可以使用http://188.75.80.115:83/WebService1.asmx?op=getKey吗?

另一个问题是回应。此Web服务的响应是:

fetch

我想我应该使用<databack xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/"> <Status>true</Status> <Error/> <Data>4yhj6mXwKTkkz4MJjaNfS/BRK8cx6/gH</Data> </databack> 。这是对的吗?

javascript react-native
1个回答
0
投票

如果您使用的是Javascript,则可以使用以下代码向Web服务发送请求。

react-native-xml2js

或者,如果您使用的是React,请使用以下代码获取更多信息

  $.ajax({
        type: "POST",
        url: "Ajax.asmx/{your-service-function}",
        data: JSON.stringify({ firstParam: 'value'}),
        contentType: "application/json; charset=utf-8",
        dataType: "json"
    });

这个链接也可以帮助你fetch(url, { method: 'POST', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }, body: JSON.stringify({ firstParam: 'yourValue', secondParam: 'yourOtherValue' }) }).then((response) => response.json()).then((responseJson) => { // response in responseJson }).catch((error) => { //handle your error });

© www.soinside.com 2019 - 2024. All rights reserved.