2008-09-17 2 views
0

웹 서비스를 쿼리하여 웹 서비스가 지원하는 메시지를 확인할 수 있습니까? 제가 작업하고있는 C# .NET 응용 프로그램은 이전 버전의 웹 서비스를 처리 할 수 ​​있어야합니다. 이전 버전의 웹 서비스는 전송하려는 메시지를 구현하지 않습니다. 웹 서비스는 버전 번호를 공개하지 않으므로 Plan B는 메시지가 정의되어 있는지 확인합니다.메시지 목록에 대한 웹 서비스 쿼리?

나는 WSDL에 대한 HTTP 요청을 만들어 구문 분석 할 수 있다고 가정하지만, 그 경로를 내려 가기 전에 더 간단한 접근 방법이 필요 없다.

업데이트 : WSDL을 가져 와서 직접 메시지를 가져 오기로 결정했습니다. 다음은 모든 메시지를 받기위한 대략적인 초안입니다.

HttpWebRequest webRequest = (HttpWebRequest) WebRequest.Create("http://your/web/service/here.asmx?WSDL"); 
webRequest.PreAuthenticate = // details elided 
webRequest.Credentials = // details elided 
webRequest.Timeout = // details elided 
HttpWebResponse webResponse = (HttpWebResponse) webRequest.GetResponse(); 

XPathDocument xpathDocument = new XPathDocument(webResponse.GetResponseStream()); 
XPathNavigator xpathNavigator = xpathDocument.CreateNavigator(); 

XmlNamespaceManager xmlNamespaceManager = new XmlNamespaceManager(new NameTable()); 
xmlNamespaceManager.AddNamespace("wsdl", "http://schemas.xmlsoap.org/wsdl/"); 

foreach(XPathNavigator node in xpathNavigator.Select("//wsdl:message/@name", xmlNamespaceManager)) 
{ 
    string messageName = node.Value; 
} 

답변

0

WSDL이이를 수행하는 방법입니다.

2

아마도 WSDL을 구문 분석하는 것이 가장 간단한 방법 일 것입니다. WCF를 사용하면 런타임에 WSDL을 다운로드 할 수 있습니다. 코드를 통해 svcutil을 실행하고 구조를 확인할 수있는 동적으로 생성 된 프록시로 끝납니다. 런타임 생성 프록시의 예는 http://blogs.msdn.com/vipulmodi/archive/2006/11/16/dynamic-programming-with-wcf.aspx을 참조하십시오.

관련 문제