- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 KSoap 从 Android 应用程序调用 ASMX 服务。它接受两个参数,都是字符串类型。当从 .NET 应用程序调用时它成功了但是当从 Android 应用程序 web 服务调用时得到空白参数,我不明白为什么..
这是相同的代码
static String NAMESPACE = "http://softco.org";
static String URL_WS = "http://www.dummy.com/newservice.asmx";
String GET_USER_DETAILS = "User_Verification";
SoapObject request = new SoapObject(NAMESPACE, GET_USER_DETAILS);
HttpTransportSE androidHttpTransport;
// add parameters and values
request.addProperty("MobileNo", String.valueOf("01234567899"));
request.addProperty("Password", String.valueOf("abcdef"));
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.encodingStyle = SoapSerializationEnvelope.XSD;
envelope.setOutputSoapObject(request);
// Web method call
SoapObject result;
try {
androidHttpTransport = new HttpTransportSE(URL_WS);
androidHttpTransport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
androidHttpTransport.call(NAMESPACE + "/" + GET_USER_DETAILS, envelope);
result = (SoapObject) envelope.getResponse();
// get the response
int propCnt = result.getPropertyCount();
request = null;
envelope = null;
androidHttpTransport = null;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
}
我使用 Fiddler 查看 Visual Studio 和 Eclipse 调用之间的区别,发现两者都为调用生成不同的 xml,不明白如何让 Ksoap 发送正确的 xml
通过 Visual Studio 调用 -
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<User_Verification xmlns="http://softco.org/"><MobileNo xmlns="">01234567899</MobileNo><Password xmlns="">abcdef</Password></User_Verification></s:Body></s:Envelope>
从 Eclipse Android 项目中调用
<?xml version="1.0" encoding="utf-8"?>
<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/"><v:Header />
<v:Body><User_Verification xmlns="http://softco.org" id="o0" c:root="1"><MobileNo i:type="d:string">01234567899</MobileNo><Password i:type="d:string">abcdef</Password></User_Verification></v:Body></v:Envelope>
任何指针都会有很大的帮助。
最佳答案
只是为了确保其他人是否陷入同样的境地并需要支持,这里是答案。
使用 PropertyInfo 类初始化要传递的参数,例如
PropertyInfo loginProcPI = new PropertyInfo();
// loginProcPI.setNamespace(NAMESPACE);
loginProcPI.setName("MobileNo");
loginProcPI.setValue("0123456789");
loginProcPI.setType(String.class);
request.addProperty(loginProcPI);
以相同的顺序设置以下两个属性(听起来可能很傻,但这就是我的问题得到解决的方式)
envelope.setAddAdornments(false);
envelope.implicitTypes = true;
希望对您有所帮助!
关于android - KSoap 调用 .NET ASMX 服务传递空参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15052001/
我有一个 asmx 服务,它接受一个 int 参数。我可以打开服务的 URL 并查看服务描述屏幕。从这里我可以将查询参数输入表单并调用 Web 服务。 有没有办法直接从 URL/查询字符串调用 Web
我有一个通过 SSL 连接运行良好的 ASMX Web 服务,但我想让这些 Web 服务在没有 SSL 的情况下无法访问。 在网络表单中,我只会使用以下代码: if (!Request.IsSecur
似乎 ASMX 隐含地不允许使用 OPTIONS 动词。我发布这个问题是因为我使用带有 POST 的 jQuery AJAX 调用,它首先在发出 POST 动词**之前向服务器查询可用的选项。 默认情
所以我发现自己遇到了一个难题。我们的应用程序中有一些旧的 asmx Web 服务,多年来一直运行良好。 突然间,他们停止了构建服务器(CI)上的工作。我说停止工作,因为即使当我导航到服务时显示服务描述
我有一个 C# .net Web 服务,需要限制其访问。我已经要求我的消费者使用用户名和密码来调用该服务。但是,有没有办法限制对实际 asmx 页面和 WSDL 的访问?我需要通过用户名/密码和 IP
描述 我有一个遗留类型 HttpRequestScoped以及使用该服务的遗留 Web 服务。为了解决遗留问题中的服务,我有一个全局解析器。这一切在 1.4 中运行良好,现在我正在使用 2.1.12,
有谁知道 SQL Server Reporting Services 中的两个 Web 服务端点 ReportService2005.asmx 和 ReportExecution2005.asmx 之
我有一个基本的 ASMX 服务,我正在尝试运行它(我宁愿使用 WCF,但无法让服务器使用它)。它在没有安全设置的情况下运行良好,但是一旦我打开安全性,我就会得到: The HTTP request i
在设计 ASMX 网络服务时,对您可以使用的类型有某种限制(序列化/反序列化)。 谁能告诉我这些限制是什么?是否可以通过在代码中添加serializable属性来绕过? 最佳答案 没有。传统的 ASM
我已经使用 CheckVat 方法创建了 ASMX 网络服务。如果我从 https://my.domain.com/VatValidation.asmx 调用此方法,我会得到成功的 json 响应,如
我正在通过经典的 asmx 网络服务传输一个大的压缩文本文件。我这样做的原因是文件的大小是 20 MB 解压缩,4MB 压缩。 这是方法。如有必要,我会提供更多信息。 [WebMethod]
我需要在客户端页面中使用 JavaScript 调用我的 Web 服务方法。我认为我没有正确引用这一点,希望您能帮助解决这一问题。 错误消息显示“CalendarHandler 未定义”。
我正在使用 ASP.NET 和 asmx 服务来访问我的 SQL 数据库的数据。 该服务既称为客户端又称为后端。 该网站将供我们的内部员工和我们的客户使用。 asmx 服务中有一些方法,如果它们未通过
我在一台服务器 1 上编写了一个 asmx 服务,在另一台服务器 2 上编写了 asp.net/c#。 我要转一个dictionary从 srv1 到 srv2。我读到 Dictionary is n
所以我在 Visual Studio 2010 中创建了一个 Web 服务。为了将它部署到 IIS Web 服务器上,我将 service.asmx、web.config 和 bin 复制到服务器(w
我有以下 ASMX 网络服务: // removed for brevity // namespace AtomicService { [WebService(Namespace = "htt
我在我的应用程序中使用第三方支付网关。支付网关提供商为集成提供了测试 asmx HTTPS URL,它有一些方法。使用 HttpWebRequest 我集成到我的应用程序中。我正在发送 SOAPReq
我正在尝试将国家/地区 Web 服务添加到下拉列表中。我已经添加了 Web 引用并拥有 discomap 和 wsdl 文件。 这是我的代码隐藏: net.webservicex.www.countr
我有一个扩展名为 .asmx 的网络服务,它指向我的网络应用程序中的一个类。添加一些代码以在应用程序启动时输出调试日志后,我可以看到每次用户访问该页面时都会创建一个新的调试日志。 我希望我可以将此 W
我有一个 asmx 服务,这些方法返回具有原始数据类型属性的自定义类。当这些属性为 null 时,它们将被排除在服务返回的 xml 之外。我希望该服务仍返回 xml 中的属性,但没有值。有办法做到这一
我是一名优秀的程序员,十分优秀!