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

I am trying to add a service link for my (.NET 4.6) project.
When I select Add Service Reference and add the WSDL URL, I see that it is correctly detected: enter image description here

I unchecked the Reuse types in all referenced assemblies checkbox, as shown below: enter image description here

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

Warning 1 Warning about a custom tool: cannot import wsdl: portType Details: when starting the WSDL import extension, an exception was thrown: System.ServiceModel.Description.XmlSerializerMessageContractImporter Error: Failed to create object of type "System.Xml.Serialization.StructMapping" for input "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 port Detail: A wsdl: binding import error occurred on which wsdl: port depends. 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: A wsdl: portType import error occurred, depending on wsdl: binding. 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 tried different options when importing, but I get these errors all the time.
I checked WSDL with www.wsdl-analyzer.com but did not find an error: enter image description here

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

SoapUI correctly shows all operations, and I can make them from SoapUI, but I need to add a link 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 cannot change the structure of this WSDL, so I have to use it as is.

EDIT: I installed XMLSpy and opened WSDL. After opening, I received a message stating that WSDL is valid.

+6
source share
4 answers

Probably the problem has already been solved in a different way (another technology, resignation from the contract), but if you are still interested, the problem is that wsdl.exe does not support the circular link in the 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 to do is define a named complex type set by 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 remove from wsdl element:

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

AFAIK You cannot invoke this operation - it is reserved for use by BIG Infomonitor.

+2
source

WSDL, he correctly determined why all the analyzers you give the correct answer. The main problem, but it uses some objects referenced by https://www.bik.pl/cc/ , it seems that it does not serve for the correct use of these objects or cannot be obtained statically, and therefore it seems that warnings on basic web service load.

Once wsdl has received definitions of the structure of the methods and types used in the WS request, there is no real need to load it dynamically. This way yo can load the WSDL file, change it if you need it, and then charge it to VS. Anyway, I suspect that you can use this web service ignoring these warnings. Have you tried

+1
source

You can try to change this part in the first of the wsdl file by replacing the links to http://bik.pl/cc/big with some equivalents, or if you can access these definitions in some other way and then save them in file and modify wsdl to access your saved files. For example, we see that you have dluznik.xsd. Also, if you see that some namespaces are no longer used in wsdl, you can directly remove it.

In any case, as said in my last comment, I think the problem is that it is just WSDL, it is not compatible with Microsoft WCF.

PD: Did you try to use the contract agreement while getting the service link? The difference with using proxy classes will be to simply use the generated objects for request / response, but this will be more of a contradiction with using this WS.

  <wsdl:definitions name="big" targetNamespace=**"http://bik.pl/cc/big"** xsi:schemaLocation=**"http://bik.pl/cc/big big.xsd"** xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:tns2="http://bik.pl/cc/big/internal" xmlns:tns=**"http://bik.pl/cc/big"** xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ws="http://www.example.com/webservice" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"> <wsdl:types> <xsd:schema targetNamespace="http://bik.pl/cc/big/internal" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:import namespace="http://bik.pl/cc/big" schemaLocation="dluznik.xsd"/> <xs:element name="brak-odp-od-im" type="xs:string"/> </xsd:schema> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:import namespace=**"http://bik.pl/cc/big"** schemaLocation="dluznik.xsd"/> </xsd:schema> </wsdl:types> 
+1
source

Your target resource was created for .Net 4.5. You will need to select a new target location using the applicable .Net that you want to use to refer to the service, or install a local copy of the wdsl.exe file on your computer.

Reinstall the .NET Framework 4.6 and install the Microsoft.NET Framework 4.6.1 Developer Package. Then use wsdl.exe, which is located here:

 C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools 

Compile the proxy class into an assembly file and specify it in your project. If necessary, add the missing assemblies (i.e. System.Web.Services.dll ).

0
source

Source: https://habr.com/ru/post/1012023/


All Articles