0
Im做與jQuery後到一個Web服務,我也得到一個SOAP響應,這樣打印SOAP響應使用jQuery
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<spGetUserResponse>
<spGetUserResult xmlns:a="http://schemas.datacontract.org/2004/07/Mobilu.SharePoint.Services.MessageContract" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:ReturnCode i:nil="true"/>
<a:ReturnMessage>OK</a:ReturnMessage>
<a:User xmlns:b="http://schemas.datacontract.org/2004/07/Mobilu.SharePoint2013Gapp.DataContract">
<b:Email/>
<b:Id>3</b:Id>
<b:LoginName>WIN-RICM5VNKO1F\Administrator</b:LoginName>
<b:Name>WIN-RICM5VNKO1F\Administrator</b:Name>
</a:User>
</spGetUserResult>
</spGetUserResponse>
</s:Body>
,我的帖子是這樣的
$.ajax({
type: "POST",
headers: {
"SOAPAction":"urn:ISharePointGappService/spGetUser"
},
contentType: "text/xml; charset=utf-8",
url: "http://localhost/WcfServiceLibrary1/Service1/",
data: x,
dataType: "xml",
//If the call succeeds
success:
function (response) {
var xmlResponse =response.documentElement;
var users = $(xmlResponse).find('User').text();
console.log(users);
console.log(response);
obj.val(users);
},
//If the call fails
error:
function (XMLHttpRequest, textStatus, errorThrown) {
obj.val(JSON.stringify(errorThrown));
console.error(errorThrown);
}
});
}
和現在的代碼我現在即時印刷像這樣的東西
3WIN-RICM5VNKO1F \ AdministratorWIN-RICM5VNKO1F \管理員
我想是打印類似:
Email: ID: 3 LoginName: WIN-RICM5VNKO1F\Administrator Name: WIN-RICM5VNKO1F\Administrator
感謝您的幫助