我是WSDL解析器的中间实现小程序。但我得到的ptobject是NULL。这与程序中提到的wsdl一起发生。我不认为WSDL是错误的,因为如果给SOAP UI提供相同的WSDL,它就会成功解析。
请您帮助理解问题的根本原因?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Net;
using System.Reflection;
using System.Web.Services.Description;
namespace ConsoleApplication14
{
class XmlSchemaReadWriteExample
{
static void Main()
{
XmlTextReader myReader = new XmlTextReader("https://domainws.ficora.fi/fiDomain/DomainNameWS_FicoraDomainNameWS.svc?wsdl");
if (ServiceDescription.CanRead(myReader))
{
ServiceDescription myDescription = ServiceDescription.Read(myReader);
Dictionary<string, Service> Services;
foreach (Service srv in myDescription.Services)
{
Services = new Dictionary<string, Service>();
Services.Add(srv.Name, srv);
foreach (Port p in srv.Ports)
{
Binding b = myDescription.Bindings[p.Binding.Name];
foreach (Object e in b.Extensions)
{
if (e is Soap12Binding || e is SoapBinding)
{
PortType ptobject = myDescription.PortTypes[b.Type.Name];
}
}
}
}
}
}
}
}
提前致谢。
Bheem。
答案 0 :(得分:0)
试试这个
static void Main()
{
XmlTextReader myReader = new XmlTextReader("https://domainws.ficora.fi/fiDomain/DomainNameWS_FicoraDomainNameWS.svc?wsdl");
if (ServiceDescription.CanRead(myReader))
{
ServiceDescription myDescription = ServiceDescription.Read(myReader);
Dictionary<string, Service> Services;
foreach (Service srv in myDescription.Services)
{
Services = new Dictionary<string, Service>();
Services.Add(srv.Name, srv);
foreach (Port p in srv.Ports)
{
Binding b = myDescription.Bindings[p.Binding.Name];
foreach (Object e in b.Extensions)
{
if (e is Soap12Binding || e is SoapBinding)
{
//only change right here:
Port ptobject = srv.Ports[b.Type.Name];
}
}
}
}
}
}
我想你正在考虑portType,也许你想要这个端口? 似乎没有为您指向的服务定义portType。
EDIT ..................
好好摆弄一下这个。加载了肥皂用户界面,并在那里...我想我可能找到了你想要的... 尝试点击https://domainws.ficora.fi/fiDomain/DomainNameWS_FicoraDomainNameWS.svc?wsdl=wsdl0
static void Main()
{
XmlTextReader myReader = new XmlTextReader("https://domainws.ficora.fi/fiDomain/DomainNameWS_FicoraDomainNameWS.svc?wsdl=wsdl0");
if (ServiceDescription.CanRead(myReader))
{
ServiceDescription myDescription = ServiceDescription.Read(myReader);
foreach (PortType pt in myDescription.PortTypes)
{
Console.WriteLine(pt.Name);
}
}
}
我注意到这个在肥皂ui的标签名称pat ...它正在拉一个额外的wsdl“wsdl0”文件。这是一个进口 从原来的Wsdl:
<wsdl:import namespace="http://domainws.ficora.fi.operations" location="https://domainws.ficora.fi/fiDomain/DomainNameWS_FicoraDomainNameWS.svc?wsdl=wsdl0"/>
您可以访问程序化网址...
myDescription.Imports[0]