Error message from svcutil.exe - what does it mean? - wcf

I've had not a lot of luck creating a WCF service with Visual Studio. It's in IIS, and it I click 'browse' on the .svc file itself, it tells me I have created a service. So I assume it's all okay to a point.
Throughout my time I came across a recommendation to use a program called svcutil.exe. I used it on my service and got the following error. I don't know what it means, so hopefully someone can shed some light on the situation.
Here's the result:
Microsoft (R) Service Model Metadata Tool
[Microsoft (R) Windows (R) Communication Foundation, Version 3.0.4506.2152]
Copyright (c) Microsoft Corporation. All rights reserved.
Attempting to download metadata from 'http://localhost/EvalServiceSite/Eval.svc'
using WS-Metadata Exchange or DISCO.
Error: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.Se
rviceModel.Description.DataContractSerializerMessageContractImporter
Error: Schema with target namespace 'http://tempuri.org/' could not be found.
XPath to Error Source: //wsdl:definitions[#targetNamespace='http://tempuri.org/'
]/wsdl:portType[#name='IEvalService']
Error: Cannot import wsdl:binding
Detail: There was an error importing a wsdl:portType that the wsdl:binding is de
pendent on.
XPath to wsdl:portType: //wsdl:definitions[#targetNamespace='http://tempuri.org/
']/wsdl:portType[#name='IEvalService']
XPath to Error Source: //wsdl:definitions[#targetNamespace='http://tempuri.org/'
]/wsdl:binding[#name='BasicHttpBinding_IEvalService']
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://tempuri.org/'
]/wsdl:binding[#name='BasicHttpBinding_IEvalService']
XPath to Error Source: //wsdl:definitions[#targetNamespace='http://tempuri.org/'
]/wsdl:service[#name='EvalService']/wsdl:port[#name='BasicHttpBinding_IEvalServi
ce']
Generating files...
Warning: No code was generated.
If you were trying to generate a client, this could be because the metadata docu
ments did not contain any valid contracts or services
or because all contracts/services were discovered to exist in /reference assembl
ies. 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.

I think this previous Stack Overflow question may help with your current question but not necessarily your problem.
Error: Cannot import wsdl:port with svcutil
You've created your WCF service and you've browsed to it in IIS so you're happy that it is working. The purpose of SVCUtil.exe is to generate classes that you can use in an application to interact with the service with compile time information on the contract members and methods.
it performs the exact same function as adding a service reference in visual studio to consume the service.
If your having trouble, i'd suggest just creating a simple console project in visual studio, adding a service reference and giving it the url of the service you've hosted in IIS. Then click "show all files" in the visual studio solution explorer and look at the reference.cs file it gives you. This will show you what information has been consumed from your service.
Edit
Hi Again,
After going through all the comments below I'm starting to see more about your problem. I think you misunderstand what it is your doing when in fact you've already achieved what you want to achieve.
The original project, the one you had with the WCF test client that worked did what you needed. It is a fully fledged WCF Service. All you needed to do was right click the solution in visual studio and publish it. If you then make sure that you make an IIS virtual directory point at your solution, through the publish wizard. Then when you run your project and then browse to that url, that will give you a service to consume for testing purposes.
What you are doing at the moment, creating a WCF project, adding that DLL to a website project is fundamentally wrong: The example you followed, presumably this one :
http://msdn.microsoft.com/en-us/library/ms733766.aspx
is about creating a WCF service in a web site project from scratch. Not about adding a pre-existing WCF project and hosting it.
Your essentially trying to do one thing in two different ways together.
Your current course of action is to either remove the DLL in your web project and then create the service there. Or host your current WCF service in IIS ( the project you downloaded from me or your original one)
At this point you have a hosted service. Then usually you have an application to interact wtih it. This you found using svcutil and can be done in one of two ways:
You create the console application and do "Add Service Reference" to the URL you have hosted in IIS.
Or you use SVC Util.exe point it at the url which generates a class file you include in your console / application.
I hope that clears things up about WCF and what stages to use various tools?
Edit 2
Just in case you don't get to the Chat:
I still think theres something wrong with your original project. I'm not sure what you mean by the one with the DLL either? if that means your website project with the dll of the WCF project, then no not that one.
I've taken the project I sent you earlier. I've hosed that in IIS so that when i browse to localhost/EvalService on my machine i get the standard
"EvalService Service
You have created a service.
To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax:"
Once I had that set up i created a console application, "added service reference" in visual studio and it consumed teh service no problem.
Try doing the above with the project I sent you and see how far you get.

Related

How can I get rid of the “The target assembly contains no service types” for self WCF hosted projects

I have a solution with several WCF self hosted projects. Every time i run a uni test i message box with this message pops up.
Because the projects were not created as WCF projects, they don't have the WCF tab in properties page were, according to many posts, i should be able to fix it by disabling option Start WCF Service Host when debugging another project in the same solution
I am running on VS 2017.
Any pointers?
Found out.
The problem was that i had a WCF Library project in the solution that was created as a regular Library project.
I fixed by adding the followin XML tag to the library project:
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{3D9AD99F-2412-4246-B90B-4EAA41C64699}">
<WcfProjectProperties>
<AutoStart>False</AutoStart>
</WcfProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
To get the tag, case anyone wonder what is it, i created an WCF library project on a dummy solution, uncheck the Start WCF Service host when debugging another project in the same solution as show in the picture below, and grab the tag from the config file.

WCF fails to import WSDL

I'm trying to "Add Service Reference" with WCF to the following wsdl: https://se-face-webservice.redsara.es/sspp?wsdl
The visual studio does not provide any warning but the reference.cs is empty and no serialization took place.
I have already tried removing the "Reuse types in specified referenced assemblies", however the serialization stills fails.
If I tried to add the service with the WcfTestClient it gives an error stating that : 'http://schemas.xmlsoap.org/soap/encoding/Array' is not defined.
Finally, when I add the wsdl through a "Add Web Reference" the serialization takes place. I'm guessing that maybe the service is using "unknown" bindings to WCF.
Is there a work around for this situation?
PS: If I use the SoapUI to generate the client everything works fine.
Your WSDL is faulty. It defines the prefix soap-enc, but does not define the schema which defines it. The WSDL is assuming that the http://schemas.xmlsoap.org/soap/encoding/ schema is automatically defined.
Perhaps this service is built on an old version of Axis? I have seen that version assume that the consumer is also built on Axis.
I've tried good old wsdl.exe for generating web service references with System.Web.Services and seems to work - generating and compilation at least :-)
Can you check it? Link to project on bitbucket. Just simple console app with references and generated assemblies.
https://bitbucket.org/polacekpavel/servicestack_27747564/src
and interesting one - generated proxy class https://bitbucket.org/polacekpavel/servicestack_27747564/src/c43b90221fae7ceb2e234552b9f57034551b3cbf/SSPPWebServiceProxyService.cs?at=master

Publish Biztalk WCF Service with multiple schema files and <includes>

What I have here is this:
A Biztalk project in Visual Studio 2010, a corresponding Biztalk application running on a Biztalk 2010 server. The receive port accepts an HL7-V3 schema, transforms it to a schema that is sent off to a SQL server 2008 instance and inserted into tables via a stored procedure. When the receive port is using the FILE adapter, all works as intended (data from the HL7 file is inserted into tables).
So, we reached the point where a web service was needed in order to expose the Receive port via the web...great we have the "Biztalk WCF Service Publishing Wizard" built right into VS2010. This is where I'm stopped in my tracks.
I can follow the wizard as far as the "Create" step, it makes it about half-way to the Extracting Schemas from Biztalk Assembly then it barfs and throws a generic error:
"The given key was not present in the dictionary"
After much searching and head scratching, I was finally led to fact that the wizard uses Xsd.exe (new to me) to generate code from the schemas. This led me to the MSDN library article Here which states that included schemas are ignored by Xsd.exe. Well, the HL7V3 schema-set for the message we are using has about 30 files altogether - all referencing each other all over the place like so:
<xs:include schemaLocation="../coreschemas/infrastructureRoot.xsd"/>
<xs:include schemaLocation="COCT_MT050002UV07.xsd"/>
<xs:include schemaLocation="COCT_MT090100UV01.xsd"/>
<xs:include schemaLocation="COCT_MT240000UV01.xsd"/>
<xs:include schemaLocation="COCT_MT150000UV02.xsd"/>
So there's my problem.
So now my question is this: Is there a way to manually create a WCF service from a Biztalk project, or better yet, just get the Wizard to work for this case? Or, just any suggestions on where to look, as this is my first Biztalk project.
My Googling has only come up with a plethora of how-to's for the Wizard.
Well, the problem has been solved, despite running down way too many rabbit holes, I stumbled upon an MSDN called Getting Started with HL7 v3 and Biztalk Server 2006 article with a little section called Schema Modifications. One of the modifications is to add Target Namespace to some of the coreschema files in HL7 v3.
I had seen this doc in the past and it mentions that this fixes the issue of them being not supported when compiling schemas in BizTalk Server. I kind of ignored it because I was getting no errors and besides, I was using 2010, not 2006 so I naively thought "that must be fixed now...no errors"
Not so, I did exactly as the document suggested and immediately deployed and ran the Biztalk WCF Service Publishing Wizard and it all worked and I was able to view the help and .wsdl pages that were generated.
I hope this helps someone in the future. Very anti-climactic for me.

Updating Service reference WCF in VS2010 SP1 (mvc3 project) TFS -- Causes other developer failing to compile

On my local machine, I consume a WCF service via the Service References. I can add to the other WCF project and check in to TFS , run the service, Go to my main project and Click on Update Service Reference, and my web.config is fine whether change is needed or not. Rebuild is fine.
However, on another developer's machine, they make a change to the WCF Service run it, and go to main project and Update Service Reference, and sometimes the web.config get trampled, it doesn't show the Url to the wcf service etc... Thus compiling project causes a issue where it cannot find the namespace for the service reference.
Then if I get latest and checkin and tell a developer to get latest, their web.config will update, but they still increasingly have a problem with the namespace for the service reference does not exist. It is running, the update to the service works. The Url in the browser shows the endpoints.... but vs 2010 sp1 has repository files that cannot find the service reference for some reason. "Are you missing an assembly reference?" Any ideas??
If in the svcutil dialog, the option to use shared assemblies is turned on, and if any signed assemblies are not an exact match, the checked in version will fail on the other machine.
You need to make sure the assemblies used have the same public key token.

Silverlight Business Application template with WCF is throwing warning

I am using the Silvelight Business Application template. I wrote a function which uses Membership.getUserList function to return the user list. I tried exposing it as Service using WCF. But when I try to compile the client side code it throws a warning saying "Client Proxy Generation for user_authentication.Web.Service1 failed'. Why does it happen?
The complete warning message is:
Warning 4 Client proxy generation for
service
'user_authentication.Web.Service1'
failed: Generating metadata files...
Warning: Unable to load a service with
configName
'user_authentication.Web.Service1'. To
export a service provide both the
assembly containing the service type
and an executable with configuration
for this service.
Details:Either none of the assemblies passed were executables
with configuration files or none of
the configuration files contained
services with the config name
'user_authentication.Web.Service1'.
Warning: No metadata files were
generated. No service contracts were
exported. To export a service, use
the /serviceName option. To export
data contracts, specify the
/dataContractOnly option. This can
sometimes occur in certain security
contexts, such as when the assembly is
loaded over a UNC network file share.
If this is the case, try copying the
assembly into a trusted environment
and running it.
Hard to say, I'm not a good enough clairvoyant yet ;-) ... Is your webservice actually already compiled, published and running? Maybe here you can find further hints:
MSDN WCF Forums: svcutil Error