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:
I've unchecked Reuse types in all referenced assemblies
as shown below:
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:
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With