Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/183.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从android访问soap服务_Android_Soap - Fatal编程技术网

从android访问soap服务

从android访问soap服务,android,soap,Android,Soap,这是对我提出的问题的跟进。经过大量调试和使用wireshark后,我意识到这就是发送的内容 POST /GetGoldPrice.asmx HTTP/1.1 user-agent: kSOAP/2.0 soapaction: http://freewebservicesx.com/GetCurrentGoldPrice content-type: text/xml connection: close content-length: 475 Host: www.freewebserv

这是对我提出的问题的跟进。经过大量调试和使用wireshark后,我意识到这就是发送的内容

 POST /GetGoldPrice.asmx HTTP/1.1 
user-agent: kSOAP/2.0 
soapaction: http://freewebservicesx.com/GetCurrentGoldPrice 
content-type: text/xml 
connection: close 
content-length: 475 
Host: www.freewebservicesx.com 

<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>
<GetCurrentGoldPrice xmlns="http://www.freewebservicesx.com/" id="o0" c:root="1">
<UserName i:type="d:string">username</UserName>
<Password i:type="d:string">111</Password></GetCurrentGoldPrice></v:Body></v:Envelope> 
HTTP/1.1 500 Internal Server Error 
Connection: close 
Date: Mon, 09 Apr 2012 04:38:50 GMT 
Server: Microsoft-IIS/6.0 
X-Powered-By: ASP.NET 
X-AspNet-Version: 2.0.50727 
Cache-Control: private 
Content-Type: text/xml; charset=utf-8 
Content-Length: 753 
POST/GetGoldPrice.asmx HTTP/1.1
用户代理:kSOAP/2.0
soapaction:http://freewebservicesx.com/GetCurrentGoldPrice 
内容类型:text/xml
连接:关闭
内容长度:475
主持人:www.freewebservicesx.com
用户名
111
HTTP/1.1500内部服务器错误
连接:关闭
日期:2012年4月9日星期一04:38:50 GMT
服务器:Microsoft IIS/6.0
X-Powered-By:ASP.NET
X-AspNet-Version:2.0.50727
缓存控制:专用
内容类型:text/xml;字符集=utf-8
内容长度:753
错误响应

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body><soap:Fault><faultcode>soap:Server</faultcode>
<faultstring>System.Web.Services.Protocols.SoapException: Server was unable to process request. ---&gt; System.ArgumentNullException: Value cannot be null. 
Parameter name: password 
   at System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(String password, String passwordFormat) 
   at GetGoldPrice.GetCurrentGoldPrice(String UserName, String Password) 
   --- End of inner exception stack trace ---</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope>

soap:服务器
System.Web.Services.Protocols.SoapException:服务器无法处理请求。--System.ArgumentNullException:值不能为null。
参数名称:密码
位于System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(字符串密码,字符串密码格式)
在GetGoldPrice.GetCurrentGoldPrice(字符串用户名、字符串密码)
---内部异常堆栈跟踪的结束---
网站期望的详细信息


XML区分大小写。改变

适用于任何地方。 请参见下面的标记定义

<?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>
    <GetCurrentGoldPrice xmlns="http://freewebservicesx.com/">
      <UserName>string</UserName>
      <Password>string</Password>
    </GetCurrentGoldPrice>
  </soap:Body>
</soap:Envelope>

一串
一串
编辑:是的,我假设你正确地关闭了标签,问题是输入错误

编辑最新版本: 通过ASP.NETC#尝试了一个示例后,我在发送以下XML时得到了响应

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <GetCurrentGoldPrice xmlns="http://freewebservicesx.com/">
      <UserName>username</UserName>
      <Password>password</Password>
    </GetCurrentGoldPrice>
  </soap:Body>
</soap:Envelope>

用户名
密码
我得到的答复是:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <GetCurrentGoldPriceResponse xmlns="http://freewebservicesx.com/">

      <GetCurrentGoldPriceResult>
        <string>0</string>
        <string>JAN 2, 2000 00:-00 PM EST</string>
        <string>+0.0</string>
      </GetCurrentGoldPriceResult>
    </GetCurrentGoldPriceResponse>
  </soap:Body>
</soap:Envelope>

0
2000年1月2日00:00美国东部时间下午1:00
+0.0
当用户名和密码不正确时,我假设这是一个相关的响应。 你能从Android生成一个类似的请求进行检查吗

编辑:添加了关于如何将XML从Android发布到web服务的链接。 请参阅:



将此添加到
system.web
标记中的
web.config
文件中

已更新问题。同样的错误仍然存在,我已经用请求格式更新了我的答案,web服务将返回一个有效的XML响应。你能检查一下从Android生成相同的代码吗?上面的代码是由Android生成并发布的。看起来好像我的密码在到达服务器时变为空,但从我的机器上发送的是罚款。知道为什么会发生这种sis吗?我强烈感觉服务器无法识别您的标记,因为XML格式不正确。你能试着发布我在回答中给出的XML吗,也许不用KSoap实现。只要尝试一下,如果这样做有效,您的KSoap就不会生成有效的XML。顺便说一句,这只是一个猜测。密码需要散列吗
<webServices>
  <protocols>
    <add name="HttpGet"/>
    <add name="HttpPost"/>
  </protocols>
</webServices>