Web服务接收空SOAP

时间:2016-11-19 08:52:00

标签: android web-services authentication soap

我的Android移动应用与网络方法进行通信。它们需要用户的身份验证,因此我在SOAP标头中发送用户名和密码,如此link。我已经检查过它并且生成正确了

globals()

但是在服务器端,Web方法 <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> <n0:AuthHeader xmlns:n0="http://tempuri.org/"> <n0:user>x</n0:user> <n0:pass>y</n0:pass> </n0:AuthHeader> </v:Header> <v:Body> <AuthenticationUser xmlns="http://tempuri.org/" id="o0" c:root="1" /> </v:Body> </v:Envelope> 收到一个空SOAP。

AuthenticationUser()

我从我的应用中的 [WebMethod] [SoapHeader("SoapHeader")] public string AuthenticationUser() { if (SoapHeader == null) return "Please provide Username and Password !" ; if (string.IsNullOrEmpty(SoapHeader.userName) || string.IsNullOrEmpty(SoapHeader.password)) return "Please provide Username and Password !!" ; //Check is User credentials Valid if (!SoapHeader.IsUserCredentialsValid(SoapHeader.userName, SoapHeader.password)) return "Invalid Username or Password !!!"; // Create and store the AuthenticatedToken before returning it string token = Guid.NewGuid().ToString(); HttpRuntime.Cache.Add( token, SoapHeader.userName, null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(30), System.Web.Caching.CacheItemPriority.NotRemovable, null ); return token; } 网络广告获得了回复

AuthenticationUser()

我不知道为什么 <?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> <AuthenticationUserResponse xmlns="http://tempuri.org/"> <AuthenticationUserResult> Please provide Username and Password ! </AuthenticationUserResult> </AuthenticationUserResponse> </soap:Body> </soap:Envelope> web方法会收到空SOAP?任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

我发现了自己的错误。我没注意标签。我试图通过authHeaderuser

发送pass
<n0:AuthHeader xmlns:n0="http://tempuri.org/">
            <n0:user>x</n0:user>
            <n0:pass>y</n0:pass>
</n0:AuthHeader>

SecuredTokenWebservice userNamepassword

必须为 <SecuredTokenWebservice xmlns="http://tempuri.org/"> <userName>x</userName> <password>y</password> </SecuredTokenWebservice>
import lxml.html

html = lxml.html.parse('https://www.racenet.com.au/horse-racing-results/happy-valley/2016-11-16')
r1class = html.xpath('//*[@id="resultsListContainer"]/div[3]/table/tbody/tr[1]/td/span[1]/text()')[0]
print(r1class)