1

I am in the middle implementation small program of WSDL parser. But I am getting ptobject is coming NULL. This is happening with the wsdl mentioned in the program. I don't think WSDL is wrong because if give the same WSDL to SOAP UI it is parsing successfully.

Could you please help in understanding the root cause of the problem ?

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];

                            }
                        }
                    }
                }
            }
        }
    }
}

Thanks in advance.

Bheem.

AGB
  • 2,230
  • 1
  • 14
  • 21
user2329702
  • 479
  • 1
  • 4
  • 12

1 Answers1

0

Try this

 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];

                        }
                    }
                }
            }
        }
    }

I think you are looking at portType when maybe you were wanting the Port? There seem to be no portTypes defined for the service you are pointing at.

EDIT..................

Ok fiddled around with this some more. loaded up soap UI and yep its there... i think i may have found what your looking for... try hiting 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);
        }
    }
}

I noticed this in the tab name pat of soap ui ... it is pulling an extra wsdl "wsdl0" file. it is an import From the original Wsdl:

  <wsdl:import namespace="http://domainws.ficora.fi.operations" location="https://domainws.ficora.fi/fiDomain/DomainNameWS_FicoraDomainNameWS.svc?wsdl=wsdl0"/>

and you can get to the URL programmatic ...

  myDescription.Imports[0]
Zobo
  • 76
  • 4