How can I make WCF talk to this web service? - wcf

This is a follow up of this question.
As suggested by #Benjamin here, I am trying to add a service reference for my wsdl now (in stead of a web reference). Here is the url to the wsdl in question:
https://eu.link.fiatauto.com/tsi/DDUWsAut.php?wsdl
The problem is that Visual Studio generates an empty codefile:
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.3603
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace test.ServiceReference1 {
}
When I try to manually generate the code using svcutil, I get the following:
C:\temp>svcutil https://eu.link.fiatauto.com/tsi/DDUWsAut.php?wsdl
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 'https://eu.link.fiatauto.com/tsi/DDUWsAut.
php?wsdl' 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.XmlSerializerMessageContractImporter
Error: The ' ' character, hexadecimal value 0x20, cannot be included in a name.
Parameter name: name
XPath to Error Source: //wsdl:definitions[#targetNamespace='urn:ddu']/wsdl:portT
ype[#name='dduPortType']
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='urn:ddu']/wsdl:port
Type[#name='dduPortType']
XPath to Error Source: //wsdl:definitions[#targetNamespace='urn:ddu']/wsdl:bindi
ng[#name='dduBinding']
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='urn:ddu']/wsdl:bindi
ng[#name='dduBinding']
XPath to Error Source: //wsdl:definitions[#targetNamespace='urn:ddu']/wsdl:servi
ce[#name='ddu']/wsdl:port[#name='dduPort']
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.
Maybe this has also something to do with the fact that there are problems when trying to use the service by adding a web reference in stead of a service reference (see my other question)?
I guess there's something wrong with that wsdl, but I can't find what exactly.
As this is a third party service which is already used by others, I don't think they will be willing to change their service, so are there any workarounds to let .NET talk to that web service?

There's a bug in the WSDL. The final part in the dduAbortRequest message has a space at the end of the name. That's probably just a bug. Tell them about it, and they'll fix it, and they'll thank you for telling them.
The WSDL is just plain invalid as-is.
<message name="dduAbortRequest">
<part name="Ticket" type="xsd:string"/>
<part name="ServiceId" type="xsd:string"/>
<part name="LoginId" type="xsd:string"/>
<part name="DocId " type="xsd:string"/> <!-- Should be "DocId" -->
</message>

Disclaimer: This is probably not a direct answer to your question BUT I just wasted 3 hours trying to fix this same error message - so I want to post this here too.
This Warning: No code was generated error message can also be triggered by lack of permissions to the app pool user on the C:\Windows\Temp directory (yes really!).
If you're getting this error I first suggest you switch to the command line if you're trying to use the 'Add Service Reference' dialog. Run this command with Fiddler open for your service URL.
svcutil.exe https://dev.example.com/ShoppingCartWS/WCF/ShoppingCartWCF.svc?wsdl
If you see any of the requests come back as 500 (in red) and the following response:
ReadResponse() failed: The server did not return a response for this request.
Then check C:\Windows\Temp and just add whatever user your app pool is running at to have permissions.
This is where I found the solution - many thanks!.

Related

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

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

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.

Error when generating service interface from wsdl using svcutil

I'm trying to run the following command line but get an error. You can try to run the command yourself to test it, but i have placed the error i'm getting below.
svcutil /noConfig /language:C# /out:ICatalog.cs /n:*,ogc.csw.ebrim http://schemas.opengis.net/csw/2.0.2/profiles/ebrim/1.0/wsdl/2.0/csw-ebrim-interface.wsdl
I tried downloading the wsdl and modifying it a few different ways to get it work. But i haven't been able to find out what to modify to get it to work.
svcutil /noConfig /language:C# /out:ICatalog.cs /n:*,ogc.csw.ebrim http://localhost/temp/csw-ebrim-interface.wsdl
Does anyone know what i can modify to get this to generate code?
Any help would be greatly appreciated.
The error i get is:
Error: Cannot obtain Metadata from http://schemas.opengis.net/csw/2.0.2/profiles/ebrim/1.0/wsdl/2.0/csw-ebrim-interface.wsdl
If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata pu
blishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.mic
rosoft.com/fwlink/?LinkId=65455.
WS-Metadata Exchange Error
URI: http://schemas.opengis.net/csw/2.0.2/profiles/ebrim/1.0/wsdl/2.0/csw-ebrim-interface.wsdl
Metadata contains a reference that cannot be resolved: 'http://schemas.opengis.net/csw/2.0.2/profiles/ebrim/1.0/wsdl/2.0/csw-e
brim-interface.wsdl'.
The content type text/xml of the response message does not match the content type of the binding (application/soap+xml; charse
t=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes
of the response were: '<?xml version="1.0" encoding="UTF-8"?>
<wsd:description
targetNamespace="http://www.opengis.net/cat/wrs/1.0/wsdl"
xmlns:tns="http://www.opengis.net/cat/wrs/1.0/wsdl"
xmlns:wrs="http://www.opengis.net/cat/wrs/1.0"
xmlns:iri="http://www.opengis.net/cat/wrs/1.0/iri"
xmlns:csw="http://www.opengis.net/cat/csw/2.0.2"
xmlns:ows="http://www.opengis.net/ows"
xmlns:wsd="http://www.w3.org/ns/wsdl"
xmlns:wsdx="http://www.w3.org/ns/wsdl-extensions"
xmlns:wsoap="http://www.w3.org/ns/wsdl/soap"
xmlns:whttp="http://www.w3.org/ns/wsdl/http"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xsi:schemaLocation="http://www.w3.org/ns/wsdl http://www.w3.org/2007/06/wsdl/wsdl20.xsd
http://www.w3.org/2001/XMLSchema http://www.w3.org/2001/XMLSchema.xsd">
<wsd:documentation>
W3C WSDL interface descriptions for the CSW-ebRIM 1.0 catalogue service. This
document shall be imported by all instance-specific service descriptions.
</wsd:documentation>
<w'.
HTTP GET Error
URI: http://schemas.opengis.net/csw/2.0.2/profiles/ebrim/1.0/wsdl/2.0/csw-ebrim-interface.wsdl
The document at the url http://schemas.opengis.net/csw/2.0.2/profiles/ebrim/1.0/wsdl/2.0/csw-ebrim-interface.wsdl was not reco
gnized as a known document type.
The error message from each known type may help you fix the problem:
- Report from 'XML Schema' is 'The root element of a W3C XML Schema should be <schema> and its namespace should be 'http://www.w3.
org/2001/XMLSchema'.'.
- Report from 'DISCO Document' is 'Discovery document at the URL http://schemas.opengis.net/csw/2.0.2/profiles/ebrim/1.0/wsdl/2.0/
csw-ebrim-interface.wsdl could not be found.'.
- The document format is not recognized.
- Report from 'WSDL Document' is 'There is an error in XML document (2, 2).'.
- <description xmlns='http://www.w3.org/ns/wsdl'> was not expected.

Unable to reference WSDL of WCF web service hosted on AppFabric

I have developed a WCF service and, while in Visual Studio 2010, I can import the WSDL without a problem. After I've deployed it to AppFabric, I get the WSDL, but several schema files referenced internally in the WSDL cannot be found, for some reason. I don't know if it's a configuration issue, or what. The error I get when I try to process the WSDL in Visual Studio 2010 follows below:
Metadata contains a reference that cannot be resolved:
'http://myserver.mydomain.com:9871/app_deploy/MyAppService.svc?wsdl'.
The WSDL document contains links that could not be resolved.
There was an error downloading 'http://myserver.mydomain.com:9871/app_deploy/MyAppService.svc?xsd=xsd0'.
The request failed with HTTP status 502: Proxy Error ( The
specified network name is no longer available. ).
Metadata contains a reference that cannot be resolved:
'http://myserver.mydomain.com:9871/app_deploy/MyAppService.svc'.
There was no endpoint listening at http://myserver.mydomain.com:9871/app_deploy/MyAppService.svc
that could accept the message. This is
often caused by an incorrect address
or SOAP action. See InnerException, if
present, for more details.
The remote server returned an error: (404) Not Found.
If the service is defined in the current solution, try building the
solution and adding the service reference again.
The error is a proxy error because it goes through a proxy, but the error is because the page isn't there. I've tried accessing http://localhost:9871/app_deploy/MyAppService.svc?xsd=xsd0 at the server, but I get 404.
Why wouldn't these xsd files being found? Is it a deployment issue?
Any help would be greatly appreciated.
Man, I finally found the problem here. I needed write permission on C:\Windows\Temp for Application Pool user!

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