Error on importing Wsdl as a connected service - wcf

I have an application that targets .NET Core.
When I try to import a wsdl file, I get the following error.
Scaffolding Code ...
Error:Error: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: Schema with target namespace 'http://xml.amadeus.com/2010/06/Session_v3' could not be found.
XPath to Error Source: //wsdl:definitions[#targetNamespace='http://xml.amadeus.com']/wsdl:portType[#name='AmadeusWebServicesPT']
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://xml.amadeus.com']/wsdl:portType[#name='AmadeusWebServicesPT']
XPath to Error Source: //wsdl:definitions[#targetNamespace='http://xml.amadeus.com']/wsdl:binding[#name='AmadeusWebServicesBinding']
Warning: Cannot import wsdl:port
Detail:
XPath to Error Source: //wsdl:definitions[#targetNamespace='http://xml.amadeus.com']/wsdl:service[#name='AmadeusWebServices']/wsdl:port[#name='AmadeusWebServicesPort']
Error: No endpoints compatible with .Net Core apps were found.
An error occurred in the tool.
Failed to generate service reference.
Is there any solution or workaround to that problem ?
Thanks.
Edit:
I have figured out the problem. To re-generate the stub, I need to run "svcutil.exe" directly from the command line (or generate the stub in some dummy C# project) because WCF Connected Services cannot generate a stub from this WSDL.
The generated code of the regarding wsdl uses following attributes that are not supported by .Net Standard 1.6.
SerializableAttribute, DesignerCategoryAttribute
When I create these two attributes manually, then I am able to make my application build.

We can add services in 2 ways from addservices or from dotnet-svcutil tool.
The problem is that your web service endpoint's WSDL uses a different way of storing the XML operation data. As Henk points out, using the wrapped flag when manually running the dotnet-svcutil tool is the solution here.
Follow these steps:
Edit your .csproj file and add the following node inside the <ItemGroup> node: <DotNetCliToolReference Include="dotnet-svcutil" Version="1.0.*" />
Open up a PowerShell terminal from within the folder where the .csproj file resides.
Run dotnet restore
Run dotnet svcutil https://smp.difi.no/ws/2.0?wsdl -wr

Related

How to set up TeamCity to use own HTTP authenticated NuGet service?

a problem is that TeamCity is unable to authorize into NuGet service which runs on same TeamCity instance.
Below you can find how the Build configuration looks now:
I also added Build Feature for NuGet Credentials:
With this configuration I receive following errors in log:
Restoring NuGet package Nuget.Package.Name.0.1.0.41.
Please provide credentials for: http://teamcity-nuget-server.cloudapp.azure.com/httpAuth/app/nuget/v1/FeedService.svc
UserName: GET http://www.nuget.org/Packages(Id='Nuget.Package.Name';,Version='0.1.0.41')
NotFound http://www.nuget.org/Packages(Id='Nuget.Package.Name';,Version='0.1.0.41') 194ms
GET http://www.nuget.org/FindPackagesById()?id='Nuget.Package.Name';
NotFound http://www.nuget.org/FindPackagesById()?id='Nuget.Package.Name'; 105ms
WARNING: Unable to find version '0.1.0.41' of package 'Nuget.Package.Name'.
C:\Windows\system32\config\systemprofile\AppData\Local\NuGet\Cache: Package 'Nuget.Package.Name.0.1.0.41' is not found on source 'C:\Windows\system32\config\systemprofile\AppData\Local\NuGet\Cache'.
C:\Windows\system32\config\systemprofile\.nuget\packages\: Package 'Nuget.Package.Name.0.1.0.41' is not found on source 'C:\Windows\system32\config\systemprofile\.nuget\packages\'.
http://teamcity-nuget-server.cloudapp.azure.com/httpAuth/app/nuget/v1/FeedService.svc: Unable to load the service index for source http://teamcity-nuget-server.cloudapp.azure.com/httpAuth/app/nuget/v1/FeedService.svc.
Cannot prompt for input in non-interactive mode.
http://nuget.org: The V2 feed at 'http://www.nuget.org/FindPackagesById()?id='Nuget.Package.Name'' returned an unexpected status code '404 Not Found'.
Errors in packages.config projects
Unable to find version '0.1.0.41' of package 'Nuget.Package.Name'.
C:\Windows\system32\config\systemprofile\AppData\Local\NuGet\Cache: Package 'Nuget.Package.Name.0.1.0.41' is not found on source 'C:\Windows\system32\config\systemprofile\AppData\Local\NuGet\Cache'.
C:\Windows\system32\config\systemprofile\.nuget\packages\: Package 'Nuget.Package.Name.0.1.0.41' is not found on source 'C:\Windows\system32\config\systemprofile\.nuget\packages\'.
http://teamcity-nuget-server.cloudapp.azure.com/httpAuth/app/nuget/v1/FeedService.svc: Unable to load the service index for source http://teamcity-nuget-server.cloudapp.azure.com/httpAuth/app/nuget/v1/FeedService.svc.
Cannot prompt for input in non-interactive mode.
http://nuget.org: The V2 feed at 'http://www.nuget.org/FindPackagesById()?id='Nuget.Package.Name'' returned an unexpected status code '404 Not Found'.
NuGet Config files used:
C:\Windows\system32\config\systemprofile\AppData\Roaming\NuGet\NuGet.Config
Feeds used:
C:\Windows\system32\config\systemprofile\AppData\Local\NuGet\Cache
C:\Windows\system32\config\systemprofile\.nuget\packages\
http://teamcity-nuget-server.cloudapp.azure.com/httpAuth/app/nuget/v1/FeedService.svc
http://nuget.org
I tried several other configurations, i.e using %teamcity.nuget.feed.server% and even %teamcity.nuget.feed.auth.server%. I also tried to remove build feature with NuGet credentials (since documentation says it doesn't need to authenticate with self hosted NuGet service). Tried to remove http://nuget.org source as well. Nothing works.
There are several issues in TeamCity: one with NuGet version 3.3.0 and higher: https://youtrack.jetbrains.com/issue/TW-44438 and the second with local agent: https://youtrack.jetbrains.com/issue/TW-44479. Please check the tickets linked. You can try to use earlier NuGet version or try the workaround.
I think your problem is that you are using NuGet 3 but the package source is pointing to the v2 Feed.
Update your "NuGet.config" (C:\Windows\system32\config\systemprofile\AppData\Roaming\NuGet\NuGet.Config) with the following package sources:
<packageSources>
<add key="NuGet official package source" value="https://api.nuget.org/v3/index.json" />
</packageSources>

I cannot add service reference(WCF library) to MVC4 in VS2012

My problem is very simple, but unfortunately I cannot figure out what's wrong. I've created a new MVC4 Internet Application project with Razor syntax, then I added another WCF Library project to this solution. I did not make any change on these codes. However, as I added the WCF project as a service reference in the MVC 4 app, I'm getting 1 Error message and 3 Warning messages:
Error 4 Custom tool error: Failed to generate code for the service
reference 'ServiceReference1'. Please check other error and warning
messages for details. c:\users\vendre\documents\visual studio
2012\Projects\MvcApplication3\MvcApplication3\Service
References\ServiceReference1\Reference.svcmap 1 1 MvcApplication3
Warning 1 Custom tool warning: Cannot import wsdl:portType Detail:
An exception was thrown while running a WSDL import extension:
System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: Could not load file or assembly 'DotNetOpenAuth.AspNet,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=2780ccd10d57b246'
or one of its dependencies. The system cannot find the file
specified.
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://tempuri.org/']/wsdl:portType[#name='IService1']
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://tempuri.org/']/wsdl:binding[#name='BasicHttpBinding_IService1']
I read some article but did not resolved my problem. If somebody know the answer for my problem, please tell me.
THX.
When you add the reference, on advanced setting remove the reuse types checkbox.
If you're experiencing this problem in 2021 with VS2019. Add a folder to the project called "Connected Services"
sometimes you need to create a folder "Service References" in project path. If you dont have this folder it should gives this path error.
If using VS 2019, check if in Solution Explorer you see "Service Reference". Than edit the project file for following
<ItemGroup>
<WCFMetadata Include="Connected Services\" />
</ItemGroup>
In Visual Studio 2019, I fixed the error (system cannot find path specified) by creating a new folder named "Connected Services" inside project folder
In Visual Studio 2022, You need to create a folder "Connected Services" in project path, via Windows Explorer, not Visual studio solution explorer'
You can try the following :
Delete the "Connected Services" folder from the project in Visual Studio
Add the service reference with right-click on the project / Add / Service Reference...
It should work and recreate the "Connected Services" folder with your new service reference.

Reflexil deobfustication error

I'm trying to modify a .net application and I'm new to this. First step is attempting to deobfuscate the code using reflexil and I get the following error:
Reflexil is unable to clean this assembly: Member 'System.RuntimeTypeHandle "bunch of obfustatcated jibberish"(System.Int32)' is declared in another module and needs to be imported
The application comes with a bunch of dll's that it certainly uses, so I assume the declaration is in one of those files. How do I import this module?
In case it's helpful, reflexil says it was obfuscated with .NET Reactor 4.1
I decided to try de4not to deobfuscate and it worked without this issue.

Generating wcf ServiceClients, reference problem

I am trying to generate ServiceClient classes.
I have 2 Projects, API and WEB.
The API project contains both ClassLibrary and DataContracts/Interface class files. I have a website which has the SVC files. WEB references the API project.
When I to generate the the Service Client classes, they generate in the API project
Here is the problem I am having
My SvcUtil command line includes /Reference: [full location of API /bin/debug/API.dll ]. It is the same path as the build output from the API project.
When I run the SvcUtil command with that /Reference, the generation fails and I see the following cutdown summary of messages.
Attempting to download metadata from
'http://id.unittest/Services/EchoService.svc?wsdl'
using WS-Metadata Exchange or DISCO.
Error: Cannot import wsdl:binding
Detail: Cannot locate operation IsSubscribed in Contract IEchoService.
XPath to Error Source: //wsdl:definitions[#targetNamespace='http://tempuri.org/']
/wsdl:binding[#name='WSHttpBinding_IEchoService']
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://tempuri.org/']
/wsdl:binding[#name='WSHttpBinding_IEchoService']
XPath to Error Source: //wsdl:definitions[#targetNamespace='http://tempuri.org/']
/wsdl:service[#name='EchoService']/wsdl:port[#name='WSHttpBinding_IEchoService']
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.
When I remove the /reference, the generation succeeds, but a duplicate set of entity classes that were used in the methods params are generated. When I try to build my API project, I get an error that there are duplicate classes names and that I should change them to partial. So, dont want and need those extra classes.
Hopefully I have provided enough information. Thanks.
The solution was to add the following switches to the svcutil command
/serializer:DataContractSerializer /serializable
Reference url: MSDN forum

MonoDevelop and AjaxControlToolkit: Register Server Tag in Mono

I know that Mono supports the AjaxControlToolkit but I don't know how to integrate it into MonoDevelop. I added AjaxControlToolkit.dll, System.Web.Extensions.dll and System.Web.Extensions.Design.dll as References in the project but when I build the project I get the warning:
/Users/user1/Projects/FirstProject/Default.aspx(1,1): Warning: Parser failed with error The tag type 'ajaxToolkit:TabContainer' has not been registered.. CodeBehind members for this file will not be added. (FirstProject)
and I when I deploy it I get the error: Unknown server tag 'ajaxToolkit:TabContainer'.
How do I register the server tag in MonoDevelop?
You can use either the <%#Register directive, or add some lines to your Web.config. See here for instructions on either approach.
Using the Web.config mechanism has the advantage that you don't need to add a directive to every page where you want to use the controls.