An exception was thrown while running a WSDL import extension - c#

I got this error while adding WSDL into my ASP.NET Core Web API project using .NET 7.0. However, it works fine using SOAP UI when company's VPN is connected.
Cannot import wsdl:port\r\nDetail: \r\nXPath to Error Source: //wsdl:definitions[#targetNamespace='urn:telmaServices']/wsdl:service[#name='telmaServices']/wsdl:port[#name='mbJIRServicePort']
Cannot import wsdl:binding\r\nDetail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on.\r\nXPath to wsdl:portType: //wsdl:definitions[#targetNamespace='urn:telmaServices']/wsdl:portType[#name='mbJIRServicePortType']\r\nXPath to Error Source: //wsdl:definitions[#targetNamespace='urn:telmaServices']/wsdl:binding[#name='mbJIRServiceBinding']
Cannot import wsdl:portType\r\nDetail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.XmlSerializerMessageContractImporter\r\nError: These members may not be derived.\r\nXPath to Error Source: //wsdl:definitions[#targetNamespace='urn:telmaServices']/wsdl:portType[#name='mbJIRServicePortType']

Related

C# MVC - Strange compilation error code -2146232576

I published a web app with C# MVC on IIS, but when I try to access the site, the server show this error; But I published the same web app in other Server and this run without issues. (I updated the NugetPackage)
Server Error in '/Outlet' Application.
Compilation Error
Description: An error occurred during the compilation of a resource
required to service this request. Please review the following specific
error details and modify your source code appropriately.
Compiler Error Message: The compiler failed with error code
-2146232576.
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.36392
I'm searching for this error code but don't find any solution, someone knows the possible solution for this error code?

Add .cs file to ASP Web Site project

I am working on an ASP.NET website and as part of the website I created a file called Global.cs which is used to hold all my helper classes. However, unfortunately, I am constantly getting errors saying there has been a problem while compiling this file. All the classes inside the file are included in single namespace - "Global".
When using it 'inline' eg. Global.SomeStaticClass.Method() :
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0103: The name 'Global' does not exist in the current context
When using "using Global;" directive:
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0246: The type or namespace name 'Global' could not be found (are you missing a using directive or an assembly reference?)
As suggested in many posts, I tried including the class in App_Code folder of my project and the namespace, "Global", is detected by the Visual Studio (no errors when adding "using Global;" directive, or when using it inline "Global.Class.Method()". However, it still fails whenever I try to access the page in the browser.
I could not find a simple solution to my problem and decided that the easiest and the most time efficient solution will be to convert my Website project to a Web Application project. You can read how to convert your Website to a Web Application at: https://blogs.msdn.microsoft.com/webdev/2009/10/29/converting-a-web-site-project-to-a-web-application-project/
With the project converted to a Web App I was able to attach my class files after compiling them to a DLL library, as it did not accept any uncompiled files inside App_Code folder by throwing an exception.
The directory '/website/App_Code/' is not allowed because the application is precompiled.
If you encounter the same issue, you can learn how to compile C# files using Developer Command Prompt here: https://msdn.microsoft.com/en-us/library/78f4aasd.aspx

Consuming OTRS TicketConnector from .NET apps

I want to consume OTRS TicketConnector webservice in a .NET app.
Normally, the easiest way to get connected to a webservice is to import its WSDL via 'Add Service Reference'. Unfortunately, OTRS TicketConnector doesn't publish the WSDL.
I've found a custom WSDL for TicketConnector here. But when I'm trying to use it in 'Add Service Reference' it leads to an empty Reference.cs showing the following errors:
Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.XmlSerializerMessageContractImporter
Error: There was a problem loading the XSD documents provided: a reference to a schema type with name 'OTRS_TicketCreate' and namespace 'http://www.otrs.org/TicketConnector/' could not be resolved because the type definition could not be found in the schema for targetNamespace 'http://www.otrs.org/TicketConnector/'. Please check the XSD documents provided and try again.
XPath to Error Source: //wsdl:definitions[#targetNamespace='http://www.otrs.org/TicketConnector/']/wsdl:portType[#name='GenericTicketConnector_Interface']
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://www.otrs.org/TicketConnector/']/wsdl:portType[#name='GenericTicketConnector_Interface']
XPath to Error Source: //wsdl:definitions[#targetNamespace='http://www.otrs.org/TicketConnector/']/wsdl:binding[#name='GenericTicketConnector_Service']
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://www.otrs.org/TicketConnector/']/wsdl:binding[#name='GenericTicketConnector_Service']
XPath to Error Source: //wsdl:definitions[#targetNamespace='http://www.otrs.org/TicketConnector/']/wsdl:service[#name='GenericTicketConnector']/wsdl:port[#name='GenericTicketConnector_endPoint']
Custom tool error: Failed to generate code for the service reference 'ServiceReference1'. Please check other error and warning messages for details.
I've tried to import the WSDL above via svcutil with no success.
Also, I've tried to import this WSDL via 'Add Web Reference' with the same results.
So my question is: how do you consume OTRS TicketConnector service from a .NET app?
Maybe you can give a code snippet or a proper WSDL that can be successfully imported with the .NET tools?
Also, I would appreciate any help in resolving issues with the WSDL errors I mentioned above.
Thanks to the OTRS community forum, I've got the answer. WSDLs for Ticket Connector are available at GitHub.

How can I correct the WSDL when the policy expression's "normalized form was too large"

So - I've been tasked with creating a proxy client to the following service, but I'm having a heck of a time generating a client that's happy with the requirements. The WSDL is located here: https://ws.conf.ebs.health.gov.on.ca:1441/EDTService/EDTService?wsdl
When I run svcutil, I get the following output:
C:\Temp>"C:\Program Files (x86)\Microsof
t SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\svcutil.exe" /t:code https://ws.conf.
ebs.health.gov.on.ca:1441/EDTService/EDTService?wsdl /out:ebs.cs /config:ebs.con
fig
Microsoft (R) Service Model Metadata Tool
[Microsoft (R) Windows (R) Communication Foundation, Version 4.0.30319.32559]
Copyright (c) Microsoft Corporation. All rights reserved.
Attempting to download metadata from 'https://ws.conf.ebs.health.gov.on.ca:1441/
EDTService/EDTService?wsdl' using WS-Metadata Exchange or DISCO.
Warning: The policy expression was not fully imported because its normalized for
m was too large.
XPath:"XPath Unavailable"
Error: Cannot import wsdl:binding
Detail: Object reference not set to an instance of an object.
XPath to Error Source: //wsdl:definitions[#targetNamespace='http://edt.health.on
tario.ca/']/wsdl:binding[#name='EDTPortBinding']
Error: Cannot import wsdl:port
Detail: There was an error importing a wsdl:binding that the wsdl:port is depend
ent on.
XPath to wsdl:binding: //wsdl:definitions[#targetNamespace='http://edt.health.on
tario.ca/']/wsdl:binding[#name='EDTPortBinding']
XPath to Error Source: //wsdl:definitions[#targetNamespace='http://edt.health.on
tario.ca/']/wsdl:service[#name='EDTService']/wsdl:port[#name='EDTPort']
Error: Cannot import wsdl:port
Detail: There was an error importing a wsdl:binding that the wsdl:port is depend
ent on.
XPath to wsdl:binding: //wsdl:definitions[#targetNamespace='http://edt.health.on
tario.ca/']/wsdl:binding[#name='EDTPortBinding']
XPath to Error Source: //wsdl:definitions[#targetNamespace='http://edt.health.on
tario.ca/']/wsdl:service[#name='EDTService']/wsdl:port[#name='EDTPort.2']
I've tried the same command using versions: 3.0.4506.2152, 4.0.30319.18020 and 4.0.30319.32559 with the same outcome. Any ideas?
I have created a proxy using WSDL.exe (inheriting from Microsoft.Web.Services3.WebServicesClientProtocol) at some point but I've had to config everything myself and I'm running into exceptions every time I receive a response (catch the exception, decrypt the response body manually and repeat). Also, I have to use MTOM which makes this custom code work even less.

svcutil.exe - Error: Cannot import wsdl:portType

I have to integrate several existing webservices in my .net application. But unfortunately, invoking the svcutil tool results in an error with the message:
Microsoft (R) Service Model Metadata Tool
[Microsoft (R) Windows (R) Communication Foundation, Version 3.0.4506.2152]
Copyright (c) Microsoft Corporation. All rights reserved.
Error: Cannot import wsdl:binding
Detail: Cannot find definition for http://grupobancolombia.com/intf/Clientes/GestionClientes/EnviarRespuestaVerificarIdentidadCliente/V1.0:EnviarRespuestaVerifi
carIdentidadCliente. Service Description with namespace http://grupobancolombia.com/intf/Clientes/GestionClientes/EnviarRespuestaVerificarIdentidadCliente/V1.0
is missing.
Parameter name: name
XPath to Error Source: //wsdl:definitions[#targetNamespace='http://grupobancolombia.com/intf/Clientes/GestionClientes/EnviarRespuestaVerificarIdentidadCliente/E
nlace/V1.0']/wsdl:binding[#name='EnviarRespuestaVerificarIdentidadCliente_HttpBinding']
Error: 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://grupobancolombia.com/intf/Clientes/GestionClientes/EnviarRespuestaVerificarIdentidadCliente/E
nlace/V1.0']/wsdl:binding[#name='EnviarRespuestaVerificarIdentidadCliente_HttpBinding']
XPath to Error Source: //wsdl:definitions[#targetNamespace='http://grupobancolombia.com/intf/Clientes/GestionClientes/EnviarRespuestaVerificarIdentidadCliente/E
nlace/V1.0']/wsdl:service[#name='EnviarRespuestaVerificarIdentidadCliente']/wsdl:port[#name='EnviarRespuestaVerificarIdentidadCliente_HttpPort']
Generating files...
Warning: No code was generated.
If you were trying to generate a client, this could be because the metadata documents did not contain any valid contracts or services
or because all contracts/services were discovered to exist in /reference assemblies. Verify that you passed all the metadata documents to the tool.
Warning: If you would like to generate data contracts from schemas make sure to use the /dataContractOnly option.
Has anyone an idea what causes this problem?
I'm seeing the same issue. I have a set of 30-odd wsdl files in a folder and am trying to create C# client classes for them all.
If I do the following
svcutil /noconfig /namespace:*,My.Required.Namespace *.wsdl
I see a lot of the error you mention (Cannot import wsdl:binding).
However, picking one file at a time
svcutil /noconfig /namespace:*,My.Required.Namespace a.wsdl
Frequently works; sometimes I have to include another file, e.g.
svcutil /noconfig /namespace:*,My.Required.Namespace b.wsdl c.wsdl
This is necessary when attempting to run svcutil on b.wsdl fails due to a dependency on c.wsdl.
Bottom line: I am not sure why I can't create contracts for all of these service definitions in one go, but it doesn't seem possible. I still have a big problem with shared types across the files; this means I effectively have to edit either third-party wsdl or the automatically generated code in order to get things to compile and run correctly.

Categories