不ASMX预计在头什么的SessionID / Cookie信息? [英] What sessionid/cookie information does asmx expect in the header?
问题描述
我打电话登录的WebMethod时这样我就可以将其发回由formsauthentication担保随后的WebMethod调用保存的HTTP头的cookie /会话ID信息。我想我只需要知道正确的头值保存,以便和发送回来。
I'm saving http header cookie/sessionid information when calling a login webmethod so I can send it back on subsequent webmethod calls secured by formsauthentication. I think I just need to know the proper header values to save so and send them back.
我是从Android应用程序使用ksoap2调用这些服务。
I'm calling these services from an android app using ksoap2.
当我一步通过code调用登录时。我看到的两个 设置Cookie
头项目:
When I step through the code when calling login. I see two Set-Cookie
header items:
Set-Cookie
ASP.NET_SessionId=wblzzrtfmli4blku2dslw5iw; path=/; HttpOnly
Set-Cookie
.ASPXAUTH=8264E023428DA853BB163504C0D375D792FC631BB873F04D196E04BAEDE7F7BB39BB5C840D0CD0613A0DD58B2456F12EE21F212D93457F3D6BC2FC343C6AE1E3DD97473B055B36379D178FE6C412EFF61CFCE7FACAF43EEAE85C46B5123CB97C3AFF156F54921993F4A2B85BEE239EAFB05AFFF58FBDA3B7EBDC59B5E0A614D8CC086B5C7DF3A884DE95DBE05F6A138DB97241666870AAF9320EDD; path=/; HttpOnly
当我从文档了解这里和这里回答,我必须退回设置Cookie
价值随后的webMethods使用饼干
。但是,正如你可以在上面看到我得到的两个Set-Cookie的头项目。那么,哪一个我发回,我可以送他们回原样或做我需要剥离出 = .ASPXAUTH
部分或别的什么吗?
As I understand from the documentation here and the answer here, I have to return the Set-Cookie
value to the subsequent webmethods using Cookie
. But as you can see above I'm getting TWO Set-Cookie header items. So which one do I send back and can I send them back as-is or do I need to strip out the .ASPXAUTH=
portion or anything else?
推荐答案
我能得到通过嗅探出的Set-Cookie头是什么样子,当我打电话给我的web应用程序内JQuery的阿贾克斯安全的服务问题的答案。
I was able to get the answer by sniffing out what the Set-Cookie header looked like when I called secured services from JQuery Ajax within my web application.
我基本上连在一起使用分号都设置cookie的值;
Basically I concatenated BOTH Set-Cookie values using a semicolon "; ".
在登录我救了它是这样的:
On the login I saved it like this:
StringBuilder cookieBuilder = new StringBuilder();
int intCookieValueCount = 0;
for (Object header : headerList) {
HeaderProperty headerProperty = (HeaderProperty) header;
String headerKey = headerProperty.getKey();
String headerValue = headerProperty.getValue();
if(headerKey != null){
if(headerKey.equals("Set-Cookie"))
{
if(intCookieValueCount!=0){
cookieBuilder.append("; ");
}
cookieBuilder.append(headerValue);
intCookieValueCount++;
}
}
}
AppSettings.setSessionCookie(cookieBuilder.toString());
和后续调用:
HeaderProperty headerPropertyObj = new HeaderProperty("Cookie", AppSettings.getSessionCookie());
@SuppressWarnings("rawtypes")
List headerList = new ArrayList();
headerList.add(headerPropertyObj);
androidHttpTransport.call(SOAP_ACTION, envelope, headerList);
这篇关于不ASMX预计在头什么的SessionID / Cookie信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!