我正在尝试使用我们的会员数据库服务(iMIS)提供的Web服务。
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("http://www.atsol.org/webservices_demo/wscontacts.asmx/");
var c = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("Username", "myname"),
new KeyValuePair<string, string>("Password", "mypassword"),
new KeyValuePair<string, string>("UpdateLoggedInDate", "false")
});
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
LoginResultsWithData r = response.Result.Content.ReadAsAsync<LoginResultsWithData>().Result;
它工作正常但是当它到达最后一行并尝试将XML反序列化为“LoginResultsWithData”对象时,它会在名称空间中遇到错误。
第1行位置错误163.期望来自命名空间“http://schemas.datacontract.org/2004/07/myProjectName.iMISContactService”的元素“LoginResultsWithData”..遇到名为“LoginResultsWithData”的'Element',名称空间为“http://www.atsol.org/wsContacts/”。
HTTP/1.1 200 OK
Date: Wed, 17 Jul 2013 19:48:59 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 4.0.30319
Cache-Control: private, max-age=0
Content-Type: text/xml; charset=utf-8
Content-Length: 1202
<?xml version="1.0" encoding="utf-8"?>
<LoginResultsWithData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.atsol.org/wsContacts/">
<ResultCode>#</ResultCode>
<ResultMessage>Succeeded</ResultMessage>
<ID>####</ID>
<InstituteContactId>####</InstituteContactId>
<IsMember>false</IsMember>
<IsInstitute>false</IsInstitute>
<CustomerTypeCode>S</CustomerTypeCode>
<BillingCategory />
<ContactStatusCode>A</ContactStatusCode>
<PaidThruDate>2099-12-31T00:00:00</PaidThruDate>
<FullName>My Name</FullName>
<FirstName>My</FirstName>
<LastName>Name</LastName>
<Informal>My</Informal>
<Roles />
<IMISCookies>
<IMISCookie>
<CookieName>ASP.NET_SessionId</CookieName>
<CookieValue>io0um25qmae35wiogsjgwrsq</CookieValue>
</IMISCookie>
<IMISCookie>
<CookieName>Login</CookieName>
<CookieValue>34E1A645EB3F4AE693EDEE665D2328264C7F064B366DE16286DF83E6D79AF7663294E1275DA22703506F3E8E3F89D02C27DAB30F2D6A4A43A3AF1A6D0DCD1A2AFDFD18073E6187111430228892A9C7EC</CookieValue>
</IMISCookie>
</IMISCookies>
</LoginResultsWithData>
在你问之前,不,我不能搞乱网络服务。 帮助?!
答案 0 :(得分:0)
也许服务提供者已经更新了他们的wsdl,并且客户端机器需要一个regen,因为发布的响应似乎与http://www.atsol.org/webservices_demo/wscontacts.asmx?WSDL中的WSDL中指定的类型一致
根据错误消息,在Web服务客户端机器中的某个位置,错误的名称空间“http://schemas.datacontract.org/2004/07/myProjectName.iMISContactService”已与响应元素“LoginResultsWithData”相关联。
WSDL和发布的响应表明与命名空间“http://www.atsol.org/wsContacts/”关联的LoginResultsWithData(在wsdl:types部分中,这由targetNamespace =“http://www.atsol.org/wsContacts/覆盖) “schema元素的属性;在响应中,这用LoginResultsWithData元素的属性xmlns =”http://www.atsol.org/wsContacts/“表示。”