Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding WSDL to project creates only types, no entry to app.config and throws three errors

I'm trying to add service reference to my (.NET 4.6) project.
When I choose Add Service Reference and add URL of WSDL I can see it is correctly discovered: enter image description here

I've unchecked Reuse types in all referenced assemblies as shown below: enter image description here

But when I click OK I get three warnings in Error List window:

Warning 1 Custom tool warning: Cannot import wsdl:portType Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.XmlSerializerMessageContractImporter Error: Unable to cast object of type 'System.Xml.Serialization.StructMapping' to type 'System.Xml.Serialization.MembersMapping'. XPath to Error Source: //wsdl:definitions[@targetNamespace='http://bik.pl/cc/big']/wsdl:portType[@name='BIG']

Warning 3 Custom tool warning: Cannot import wsdl:port Detail: There was an error importing a wsdl:binding that the wsdl:port is dependent on. XPath to wsdl:binding: //wsdl:definitions[@targetNamespace='http://bik.pl/cc/big']/wsdl:binding[@name='BIGBinding'] XPath to Error Source: //wsdl:definitions[@targetNamespace='http://bik.pl/cc/big']/wsdl:service[@name='BIG']/wsdl:port[@name='BIG']

Warning 2 Custom tool warning: Cannot import wsdl:binding Detail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on. XPath to wsdl:portType: //wsdl:definitions[@targetNamespace='http://bik.pl/cc/big']/wsdl:portType[@name='BIG'] XPath to Error Source: //wsdl:definitions[@targetNamespace='http://bik.pl/cc/big']/wsdl:binding[@name='BIGBinding']

I've tried different options while importing, but I get those errors all the time.
I've validated WSDL using www.wsdl-analyzer.com but it shows no error: enter image description here

Here is quality report: https://www.wsdl-analyzer.com/qualityReport/show/1784995829?version=1

SoapUI correctly shows all operations and I'm able to do them from SoapUI, but I need to add reference to my project in Visual Studio.

Below are links to WSDL and XSD:

https://wasstt.infomonitor.pl/39D97477-0709-455f-A7C8-6498B600AC5A/ws/BIG/WEB-INF/wsdl/dluznik.wsdl

https://wasstt.infomonitor.pl/39D97477-0709-455f-A7C8-6498B600AC5A/ws/BIG/WEB-INF/wsdl/dluznik.xsd

How can I import this WSDL into my project? I'm unable to modify structure of that WSDL, so I must use it as it is.

EDIT: I've installed XMLSpy and opened that WSDL in it. After opening I got message saying that WSDL is valid.

like image 479
Misiu Avatar asked Nov 04 '16 09:11

Misiu


People also ask

What is WSDL used for?

WSDL is an XML notation for describing a web service. A WSDL definition tells a client how to compose a web service request and describes the interface that is provided by the web service provider.

How do I create a WSDL file in Visual Studio?

In Visual Studio, create or open an Enterprise Server Application project that contains a WSDL file that describes a COBOL application. In the Solution Explorer, right-click the WSDL file; then select Generate Web Service from the context menu.


1 Answers

Probably the problem has already been solved in a different way (other technology, resignation from the contract), but if you are still interested, the problem is that wsdl.exe don't support circular reference in element definition.

<xs:element name="raport-z-rej-zap">
    <xs:complexType>
    <!-- ... -->
        <xs:element ref="tns:raport-z-rej-zap" minOccurs="0" maxOccurs="unbounded" />
    <!-- ... -->
    </xs:complexType>
</xs:element>

All You need is to define named complex type insted of anonymous:

<xs:element name="raport-z-rej-zap" type="tns:Raport-z-rej-zap">
    <xs:annotation>
        <xs:documentation>Struktura raportow z Rejestru Zapytan (ref. 6.6)</xs:documentation>
    </xs:annotation>
</xs:element>
<xs:complexType name="Raport-z-rej-zap">
    <xs:choice>
        <xs:sequence>
            <xs:element name="naglowek" type="tns:TypNaglowekRaportu" />
            <xs:element name="pytajacy" type="tns:TypDanePodmiotuPytajacego" minOccurs="0" />
            <xs:element name="dane-zap" type="tns:TypDaneZapytaniaZRejZap" minOccurs="0" />
            <xs:element name="uwagi-i-ostrz" type="tns:TypUwagOstrzezen" minOccurs="0" />
            <xs:element name="podmiot" minOccurs="0" maxOccurs="unbounded">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="dane-podm" type="tns:TypDanePodmiotu" />
                        <xs:element name="tresc-rap" minOccurs="0" maxOccurs="unbounded">
                            <xs:annotation>
                                <xs:documentation>Tresc uprzednio przekazanego raportu</xs:documentation>
                            </xs:annotation>
                            <xs:complexType>
                                <xs:choice>
                                    <xs:element ref="tns:raport-fin" minOccurs="0" maxOccurs="unbounded" />
                                    <xs:element ref="tns:raport-dok" minOccurs="0" maxOccurs="unbounded" />
                                    <xs:element name="raport-z-rej-zap" type="tns:Raport-z-rej-zap" minOccurs="0" maxOccurs="unbounded" />
                                </xs:choice>
                            </xs:complexType>
                        </xs:element>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element name="suma-kontr" type="tns:TypSumaKontrolna" minOccurs="0" />
        </xs:sequence>
        <xs:element name="blad-przetw" type="tns:TypBladPrzetw" />
        <xs:element name="blad-struktury" type="tns:TypKomunikatAdministracyjny">
            <xs:annotation>
                <xs:documentation>zadanie operacji na bazie danych odrzucone z powodu bledow struktury (rezultat = blad struktury).</xs:documentation>
            </xs:annotation>
        </xs:element>
        <xs:element name="certyfikat" type="tns:TypRaportCertyfikat" />
    </xs:choice>
</xs:complexType>

Or delete from wsdl element:

<wsdl:operation name="pobranie-raportu-z-rej-zap">

AFAIK You can't call this operation - it is reserved for BIG Infomonitor use.

like image 179
Tomasz Bochyński Avatar answered Oct 02 '22 09:10

Tomasz Bochyński