Kri*_*r L 13 .net c# soap wsdl
我正在与第三方合作,将我们的一些系统与他们的系统集成在一起,它们为我们提供了一个SOAP接口,用于在其连接的系统中进行某些请求和更改.对我来说问题是他们不提供WSDL文件供我使用.如果我有一个WSDL文件,那么运行提供的.NET命令(wsdl.exe)并生成一个代理类来与服务进行交互就是一件简单的事情.
没有WSDL文件,有一种"简单"的方法吗?我拥有可以访问的所有功能以及需要发送的参数以及我应该期待的回报.
拥有没有WSDL文件的SOAP服务是否常见?(我问这个,因为我们将来会增加更多的外部系统)
有没有人针对无WDSL服务完成代理类或任何其他形式的客户端,并且有任何关于如何做的好指示?
小智 7
string EndPoints = "http://203.189.91.127:7777/services/spm/spm";
string New_Xml_Request_String = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><soapenv:Body><OTA_AirLowFareSearchRQ EchoToken=\"0\" SequenceNmbr=\"0\" TransactionIdentifier=\"0\" xmlns=\"http://www.opentravel.org/OTA/2003/05\"><POS xmlns=\"http://www.opentravel.org/OTA/2003/05\"><Source AgentSine=\"\" PseudoCityCode=\"NPCK\" TerminalID=\"1\"><RequestorID ID=\"\"/></Source><YatraRequests><YatraRequest DoNotHitCache=\"true\" DoNotCache=\"false\" MidOfficeAgentID=\"\" AffiliateID=\"\" YatraRequestTypeCode=\"SMPA\"/></YatraRequests></POS><TravelerInfoSummary><AirTravelerAvail><PassengerTypeQuantity Code=\"ADT\" Quantity=\"1\"/><PassengerTypeQuantity Code=\"CHD\" Quantity=\"1\"/><PassengerTypeQuantity Code=\"INF\" Quantity=\"1\"/></AirTravelerAvail></TravelerInfoSummary> <SpecificFlightInfo><Airline Code=\"\"/></SpecificFlightInfo><OriginDestinationInformation><DepartureDateTime>" + DateTime.Now.ToString("o").Remove(19, 14) + "</DepartureDateTime><OriginLocation CodeContext=\"IATA\" LocationCode=\"DEL\">" + Source + "</OriginLocation><DestinationLocation CodeContext=\"IATA\" LocationCode=\"BOM\">" + Destincation + "</DestinationLocation></OriginDestinationInformation><TravelPreferences><CabinPref Cabin=\"Economy\"/></TravelPreferences></OTA_AirLowFareSearchRQ></soapenv:Body></soapenv:Envelope>";
protected string HttpSOAPRequest_Test(string xmlfile, string proxy)
{
try
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.InnerXml = xmlfile.ToString();
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(EndPoints);
req.Timeout = 100000000;
if (proxy != null)
req.Proxy = new WebProxy(proxy, true);
req.Headers.Add("SOAPAction", "");
req.ContentType = "application/soap+xml;charset=\"utf-8\"";
req.Accept = "application/x-www-form-urlencoded"; //"application/soap+xml";
req.Method = "POST";
Stream stm = req.GetRequestStream();
doc.Save(stm);
stm.Close();
WebResponse resp = req.GetResponse();
stm = resp.GetResponseStream();
StreamReader r = new StreamReader(stm);
string myd = r.ReadToEnd();
return myd;
}
catch (Exception se)
{
throw new Exception("Error Occurred in AuditAdapter.getXMLDocumentFromXMLTemplate()", se);
}
}
Run Code Online (Sandbox Code Playgroud)
我还没有在无法访问 WSDL 文件的情况下构建 SOAP 接口,但该格式的文档记录相当齐全。您最好的选择可能是创建您自己的简化 WSDL 文件,该文件反映您对所订阅的服务的了解......
如果您决定走这条路,现有的 stackoverflow 问题会指向一些用于验证 WSDL 的工具。
| 归档时间: |
|
| 查看次数: |
28759 次 |
| 最近记录: |