2011-07-27 4 views
3

TFS에서 활성 프로젝트에 대한 정보를 얻는 자바 스크립트 클라이언트를 빌드하려고합니다.TFS SOAP 웹 서비스 용 자바 스크립트 클라이언트 빌드

TFS에는 SOAP 끝점이 있으므로 wsdl2js (http://cxf.apache.org/docs/tools.html)를 사용하여 로컬 프록시를 생성 한 다음 해당 프록시 (예 : 목록 프로젝트 등)에 필요한 기능을 호출하려고합니다.

function showresponse(response) 
    { 
     alert("rasp"); 
    } 

    function showerror(error) 
    { 
     alert('error'); 
    } 


    var test=new ClassificationSoap(); 
    test.url="http://192.168.48.130:8080/Services/v1.0/CommonStructureService.asmx"; 
    test.ListAllProjects(showresponse,showerror); 

그러나, 응답 기능 중 어느 것도 호출됩니다

여기에 내 JS 코드입니다. 내가 피들러을 발사

POST /Services/v1.0/CommonStructureService.asmx HTTP/1.1 
Host: 192.168.48.130 
Content-Type: text/xml; charset=utf-8 
Content-Length: length 
SOAPAction: "http://schemas.microsoft.com/TeamFoundation/2005/06/Services/Classification/03/ListAllProjects" 

<?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> 
    <ListAllProjects xmlns="http://schemas.microsoft.com/TeamFoundation/2005/06/Services/Classification/03" /> 
    </soap:Body> 
</soap:Envelope> 

, 여기 내 원시 요청 보지 않는다 방법은 다음과 같습니다 : CommonStructureService.asmx에 따르면

여기에 요청이 보일 것입니다 방법

OPTIONS http://192.168.48.130:8080/Services/v1.0/CommonStructureService.asmx HTTP/1.1 
Host: 192.168.48.130:8080 
Connection: keep-alive 
Cache-Control: max-age=0 
Access-Control-Request-Method: POST 
Origin: null 
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.122 Safari/534.30 
Access-Control-Request-Headers: MessageType, SOAPAction, Content-Type 
Accept: */* 
Accept-Encoding: gzip,deflate,sdch 
Accept-Language: en-US,en;q=0.8 
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3 

당신이 볼 수 있듯이, 아니이있다 XML이 전송되었습니다.

HTTP/1.1 401 Unauthorized 
Content-Length: 1656 
Content-Type: text/html 
Server: Microsoft-IIS/6.0 
WWW-Authenticate: NTLM 
X-Powered-By: ASP.NET 
Date: Wed, 27 Jul 2011 17:14:08 GMT 
Proxy-Support: Session-Based-Authentication 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
<HTML><HEAD><TITLE>You are not authorized to view this page</TITLE> 
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=Windows-1252"> 
<STYLE type="text/css"> 
    BODY { font: 8pt/12pt verdana } 
    H1 { font: 13pt/15pt verdana } 
    H2 { font: 8pt/12pt verdana } 
    A:link { color: red } 
    A:visited { color: maroon } 
</STYLE> 
</HEAD><BODY><TABLE width=500 border=0 cellspacing=10><TR><TD> 

<h1>You are not authorized to view this page</h1> 
You do not have permission to view this directory or page using the credentials that you supplied because your Web browser is sending a WWW-Authenticate header field that the Web server is not configured to accept. 
<hr> 
<p>Please try the following:</p> 
<ul> 
<li>Contact the Web site administrator if you believe you should be able to view this directory or page.</li> 
<li>Click the <a href="javascript:location.reload()">Refresh</a> button to try again with different credentials.</li> 
</ul> 
<h2>HTTP Error 401.2 - Unauthorized: Access is denied due to server configuration.<br>Internet Information Services (IIS)</h2> 
<hr> 
<p>Technical Information (for support personnel)</p> 
<ul> 
<li>Go to <a href="http://go.microsoft.com/fwlink/?linkid=8180">Microsoft Product Support Services</a> and perform a title search for the words <b>HTTP</b> and <b>401</b>.</li> 
<li>Open <b>IIS Help</b>, which is accessible in IIS Manager (inetmgr), 
and search for topics titled <b>About Security</b>, <b>Authentication</b>, and <b>About Custom Error Messages</b>.</li> 
</ul> 

</TD></TR></TABLE></BODY></HTML> 

그래서 기본적으로 그것은 인증을 필요로 말한다 :

다음은 원시 응답입니다.

showerror 함수가 호출되지 않는 이유는 무엇입니까? 내 고객은 사용자에게 자격 증명을 요청하는 방법을 어떻게 알 수 있습니까?

또한 인증은 어떻게 작동합니까?

는 내가 포함하는 인증 헤더 보낼 필요가 알고 : 64 기수로 인코딩 된 "사용자 패스를",하지만 난 생성 된 Classification.js이에 대한 참조를 찾을 수 없습니다

감사

+0

자바 스크립트 클라이언트를 만들었습니까? 그것은 당신이 공유 할 수있는 것입니까? –

+0

아니요. 나는 WCF REST webservice를 만들고 tfs api를 사용하여 tfs 서버에서 사용자를 인증하는 다른 접근법을 사용했습니다. 이후 서비스는 요청 된 정보 (프로젝트, 사용자 스토리 등)로 jsons를 반환했습니다. – Timo89

답변

1

당신 첫 번째 요청은 POST가 아닌 OPTIONS 요청이었습니다. XMLHTTPRequest를 사용하여 교차 원 서버에 요청을 보내시겠습니까? 그렇다면 CORS를 통해 서버가 해당 비행 전 OPTIONS 요청에 대한 응답으로 Access-Control-Allow-Origin 지시문을 반환하도록 구성해야합니다.

관련 문제