웹 서비스를 쿼리하여 웹 서비스가 지원하는 메시지를 확인할 수 있습니까? 제가 작업하고있는 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;
}