[英]portType is coming null in wsdl parsing
我是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。
嘗試這個
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。
編輯..................
好的,還有更多的東西擺弄。 加載了肥皂用戶界面,然后在那里......我想我可能已經找到了你想要的東西......試着點擊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"/>
你可以到達程序化的URL ......
myDescription.Imports[0]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.