wsdl.exe with SSL/TLS - c#

I've been trying to give more information to the provider about the error I'm getting when trying to consume one of his WS.
They asked me to use wsdl.exe to execute the following command:
wsdl.exe /l:CS /protocol:SOAP /verbose /sharetypes https:example.com/?wsdl
I did it, and got:
Error: There was an error processing 'https://example.oom?wsdl'.
- There was an error downloading 'https://example.com?wsdl'.
- The request was aborted: Could not create SSL/TLS secure channel.
Thing is that I have a cert to navigate that "https://example.com?wsdl" and I think it's properly installed.
When I try to go to that URL in IE I only need to select the cert from a list and give it a certain permission. Then the wsdl is displayed.
I asked my WS provider to tell me how can I tell the command: "use ssl. Use this cert". They told me to ask my networking team, but I've got no such thing, so I asked google, and I found: 1) enable SSL/TLS (if that means go to: IE > Internet Options > Advanced > SSL/TLS enabled, I did it) and 2) check the cert is installed and available. Which I think it is.
Can anyone tell me what can I do?
How is it that the cert is installed, but the command can't reach it?

Are you saying that you need to supply a client-side certificate to navigate to that web page? If that's the case, I'm not sure you can use the wsdl.exe tool directly to connect to it.
But you don't need to. Load the WSDL up in IE and save it as XML, then point wsdl.exe to the local copy of the file. The only difference in the output will be the default endpoint address embedded in the proxy class. You should be setting that value up at run-time anyway, but you can always just edit the auto-generated C# code and fix it. The actual service and data contracts and the implementation code will be exactly the same.
One caveat: if this WSDL is produced by WCF, you have some extra work to do. WCF produces a federated WSDL definition: often times there are a half-dozen or more separate XSD files that make up the whole WSDL definition. Typically, the connection-related information is found in one file, while the type information is pulled in from somewhere else using tags that look like this:
<wsdl:types>
<xsd:schema targetNamespace="foo">
<xsd:import schemaLocation="https://localhost/Foo.svc?xsd=xsd0" namespace="foo"/>
<xsd:import schemaLocation="https://localhost/Foo.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/>
<xsd:import schemaLocation="https://localhost/Foo.svc?xsd=xsd2" namespace="http://schemas.datacontract.org/2004/07/Foo.Model"/>
<xsd:import schemaLocation="https://localhost/Foo.svc?xsd=xsd3" namespace="http://schemas.datacontract.org/2004/07/System.Collections.ObjectModel"/>
</xsd:schema>
</wsdl:types>
If that's true, you will need to do two things to get the WSDL you need:
Download all of the files that are referenced; these will be either <?include> directives or <wsdl:import> tags found within the other XMLs file, which pull in a second one. You need to check each new file, as there are often second and third level imports. Put everything into one folder.
Edit all of those include references to remove the URLs and just use local file references.
Once that's done, wsdl.exe should run fine. (In .NET 4.5 there is built-in support for flattening the WSDL file out dynamically, but until then you have to do it manually.)

Download the wsdl into your browsersave it to file and then use wsdl.exe on the local file.

Related

Supplant a BizTalk WCF service

I have a WCF service based on BizTalk, I'm not sure how it was deployed or generated but as far as I know it was made using the BizTalk wizard for publishing WCF services. The problem is the BizTalk server installation was removed and now the service still here but it doesn't work, when i invoke the URL the service responses an exception: The BizTalk receive location may be disabled. I need to generate a WCF service in order to replace that service. I have one example request and response and the folder with the service, with a lot of stuff, XML, definitions, etc but there are no DLLs. The SVC markup has a reference to a BizTalk logic.
<%# ServiceHost Language="c#" Factory="Microsoft.BizTalk.Adapter.Wcf.Runtime.WSHttpWebServiceHostFactory, Microsoft.BizTalk.Adapter.Wcf.Runtime, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
So here goes my question, does anybody know how to generate a service based on request or response to supplant the service.
If you only have the request and response xml then it's a bit tricky. Even if you manage to recreate the service there is no guarantee that existing service consumers will be able to continue to call the service without any change. However, if you want to have a go, this rough guide will help:
Extract the operation signature from the soap request and response
This should be simple. Just look at the part of the request xml which defines the SOAP body. As an example:
<soap:Body xmlns:m="http://www.bookshop.com/prices">
<m:GetBookPrice>
<param1 xsi:type="xs:string">Metro 2033</param1>
</m:GetBookPrice>
</soap:Body>
This shows that the operation name was called GetBookPrice, and that it takes a string as an argument. Now look at the soap body for the response, for example:
<soap:Body xmlns:m="http://www.bookshop.com/prices">
<m:GetBookPriceResponse>
<return xsi:type="xs:decimal">5.99</return>
</m:GetBookPriceResponse>
</soap:Body>
This tells us that the return type of the operation was decimal:
public decimal GetBookPrice(string bookName);
So now you can recreate the service operation in a vanilla WCF service.
It's possible that the service definition included complex types rather than primitives, in which case you need to infer the types from the request/response xml. If the types are too large, you can try to automatically infer them by:
Infer XSD from XML - you'll need to extract just the request and response types from the request/response files, then run them through xsd.exe, which will try to generate the XSD schemas for your request/response types.
Infer CS from XSD - once you have the XSD files, again use xsd.exe to infer the classes for these files. You can then annotate these classes with the DataContract and DataMember attributes and then you can use them in your service definition.
In conclusion, it's not a task I envy you for - even if you manage to faithfully reconstruct the service and type definitions, you may still find that existing clients cannot call the service based on having missed some optional data which was not present in the request/response files you have.
If you create a client for the service in a blank project using Visual Studio (References > "Add Service Reference") you will get the interface that you need to implement (as well as POCOs for all the parameters).
Then create a new WCF project and use that interface and those classes as your contract.
This way you will honour the existing schema without having to manually interpret it.
Look for WcfServiceDescription.xml file in your service folder, its under \App_Data\Temp folder of your service physical folder (you can check IIS virtual directory where its pointing to find the physical path).
Use this file to publish the service again. Based on the definition in it, make sure, you deploy required assemblies to GAC (e.g. schema or orchestration assemblies) before publishing the service again.
Then you can use BtsWcfServicePublishing.exe tool which you can download from http://www.microsoft.com/en-us/download/details.aspx?id=21973 from command prompt. On this exe pass the WcfServiceDescription.xml file along with its full path
In the end, I used an ashx handler for procesing the request (cambined with the other responses were very helpfull) xml-> generate xsd -> parse and read request. The only problem is the .ashx termination.

How to make sense of PHP WSDL

A client (company, not application) has provided a URL to a php-based web service. When I try to work from its url with SOAPUI, WCFTestClient or SvcUtil, all give various levels of non-success.
It looks very much as though there is a case-sensitivity issue. SvcUtil indicates, for example:
Error: There was an error verifying some XML Schemas generated during
export: Type 'http://www.w3.org/2001/XMLSchema:datetime' is not
declared.
Note the case of what I believe should be DateTime.
Is there a way (tool?) that can help generate the C# client side/translate from case-insensitive WSDL?
Note, my web service experience is modest and the customer's is even less so sorry for the basic question. Thanks!

Integrating PayPal in C#/.NET Solution using WSDL (SOAP)

Environment :
Visual Studio 2010 Professional
.NET Framework 4
C#
Added Service Reference using the following WSDL : https://www.paypalobjects.com/wsdl/PayPalSvc.wsdl
Problem 1 : When compiled simply like this, get a bunch of errors from the Reference.cs file. Looks like namespace errors. It mentions that it cannot find the Service Reference Namespace in my project's Namespace. Therefore, I went into the Reference.cs file and whereever I got this error, I removed the project's namespace before the method names, and now it compiles.
Finally getting access to all classes.
Created and populated DoDirectPaymentReq and CustomSecurityHeader objects with the required properties.
Created an instance of PayPalAPIAAInterfaceClient class, which contains the method DoDirectPayment which takes in the arguments of type CustomSecurityHeader and DoDirectPaymentReq. Looks like this :
using (var client = new **PayPalAPIAAInterfaceClient**())
{
var credentials = new CustomSecurityHeaderType
{
Credentials = new UserIdPasswordType
{
Username = "xxxxxxxx#xxxxxx.com",
Password = "xxxxxxx",
Signature = "jksadfuhasfweakjhasf"
}
};
_doDirectPaymentResponseType = client.DoDirectPayment(ref credentials, _doDirectPaymentReq);
}
Problem 2 : After writing a TestMethod for the method which contains the above code, I get the error as follows :
System.InvalidOperationException: Could not find default endpoint element that references contract 'Paypal.PayPalAPIAAInterface' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
at System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint, String configurationName)
at System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName, Configuration configuration)
at System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName)
at System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address)
at System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress)
at System.ServiceModel.EndpointTrait`1.CreateSimplexFactory()
at System.ServiceModel.ClientBase`1.CreateChannelFactoryRef(EndpointTrait`1 endpointTrait)
at System.ServiceModel.ClientBase`1.InitializeChannelFactoryRef()
at System.ServiceModel.ClientBase`1..ctor()
at PaymentEngine.Paypal.PayPalAPIAAInterfaceClient..ctor() in Reference.cs: line 30063
Therefore, so far I have not been able to make a successful transaction using PayPal SOAP protocol via using WSDL in C#.
I was under the impression that this is very simple. Simply Add Service Reference and utilize the Classes with their properties and methods created in the proxy from WSDL.
Where am I going wrong ?
Am I using the wrong WSDL ? I'd like to test against Sandbox first and then go Live.
If I am right with the WSDL, looks like the class PayPalAPIAAInterfaceClient doesn't know its endpoint, which I don't know if I am suppose to set manually or not since its already there in the WSDL definition at the end (check it out). I think the class itself should know which endpoint to call depending on whether I am using Signature or Certificate to populate CustomSecurityHeaderType.
But how does the PayPalAPIAAInterfaceClient class know whether I am trying to call into the Sandbox (testing) or it is a live transaction ?
PayPal used to have two different WSDLs for Sandbox and for Live. They can be found here :
->https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_soap_PayPalSOAPAPIArchitecture
After speaking to their support I was asked to use the following WSDL for both Sandbox and Live:
->https://www.paypalobjects.com/wsdl/PayPalSvc.wsdl
But how do I tell the PayPalAPIAAInterfaceClient class when it is suppose to perform Live or Sandbox tests. And also to which end point to use depending on my method of SOAP and Signature. The endpoints from PayPal are mentioned here :
https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/howto_api_endpoints
HELP !
You have a few problems here, but none should be too painful to resolve. First of all, when I add a Service Reference to the WSDL you link at the top of your post I don't have any of the problems with namespaces that you describe. It could be that your own namespaces/references are conflicting somehow with the auto-generated terms, or perhaps that you selected some strange option during the add reference process? A delete-and-re-add might solve the problem, or I guess you can just ignore it since you've already worked around it. (It is kind of a hassle to edit auto-generated code, however, so you should plan on a fix eventually.)
To resolve the InvalidOperationException, you probably just need to specify one of the endpoints that Visual Studio has automatically added to your app.config file. You should have something like this in your config file:
<system.serviceModel>
<client>
<endpoint name="PayPalAPI" ... />
<endpoint name="PayPalAPIAA" ... />
</client>
</system.serviceModel>
You can pass the name of the endpoint you want to the constructor of the proxy class. There are other options to solve this problem, but just specifying an endpoint is easy and clean. (Note: if you don't have this section in your config file, then something went wrong during the Add Service Reference phase. Again I would just suggest resetting your project and re-adding the reference.)
Finally, you don't want to use a using block when you make use of the proxy class in spite of it being IDisposable. Basically, there's a design bug in WCF.
I had the same problem, because I was doing unit testing.
You have to copy the application.config file to the test project, otherwise it won't find the WCF config.

BES Administration WSDL Generation Documentation Incorrect

I'm trying to administer my BES 5.0 servers using C# and the following URL seems to not only tell me to generate a WSDL for an incorrect namespace (does not exist) but it also generates collisions.
http://docs.blackberry.com/en/developers/deliverables/16633/Generate_the_client_proxy_925487_11.jsp
What is the correct way to set up the WSDL for the BES admin api?
The correct way is the following command, one line, with the FQDN of the server:
wsdl.exe /sharetypes /out:C:\Temp\proxy.cs https://myFQDN/baaws/core/ws?wsdl https://myFQDN/baaws/core/wsutil?wsdl https://myFQDN/baaws/emailexchange/ws?wsdl https://myFQDN/baaws/dispatcher/ws?wsdl
Alternate WSDL for Groupwise: (append) baaws/emailgroupwise/ws?wsdl
Alternat WSDL for LotusNotes: (append) baaws/emaildomino/ws?wsdl

Accessing Salesforce Webservice API using C#

I havent worked with that Salesforce API before, so I am a bit stuck on how to connect to the salesforce service.
So far I understood that I have to generate a wsdl file for my account or rather the account of my customer (step 1). So far, so good.
But now the Quickstart (http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_quickstart_steps.htm) says something about "Import the WSDL File into your development platform" (step 2).
How do I import a wsdl file into Visual Studio 2008? I cant find the "Add Web Reference" option which is mentioned in the quickstart.
And if I only need to use the WSDL, what use has the Salesforce Dotnet API package which can be downloaded from the salesforce website
(http://wiki.developerforce.com/index.php/Salesforce_Dotnet_API)?
Are there any gotchas I should watch out for when developing applications that use the salesforce API?
If you follow the directions in Binz' answer, you should be able to add a web service reference using Visual Studio.
The "Salesforce Dotnet API package" on the wiki site is not required to access the SalesForce API, it's just a library that tries to abstract it.
As far as gotchas and other things to know, I would recommend that you read chapter 6 of the Force.com Cookbook. You have to sign up for a force.com developer account (free). Most of the things you'll need to be aware of are covered in this chapter. Here are a few of them:
logging in / logging out - session
management
query / queryMore pattern (needed if
you're going to pull large sets of
data from SalesForce)
how to construct a wrapper class -
there is some sample vb.net code you
can download as well
One other thing to note, if you're going to use SOQL to query your SalesForce data, and you need to filter on a SalesForce date field, you'll need to format the date string. Here's one way to do it:
public static string FormatDateForQuery(DateTime dateToFormat, bool includeTime)
{
if (includeTime)
{
return dateToFormat.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss+00:00");
}
else
{
return dateToFormat.ToUniversalTime().ToString("yyyy-MM-dd");
}
}
For Visual Studio 2008 you need to select 'Add Service Reference', then click the 'Advanced' button on the bottom left of the dialogue. There should then be a button on the bottom of that dialogue that says 'Add Web Reference'. You should be able to then select your wsdl file and a service client proxy will be auto genned for you by VS.
To create the WSDL file, go to (your name, top right), set up, develop > api > generate enterprise wsdl > generate. In Chrome, click save page as and put that file in the c drive. In Visual Studio, go to add service reference > advanced > add web reference. Point to the file you downloaded: file:///c:/wsdl.jsp.xml
There is a parsing issue when using .NET 2.0 with date time fields in salesforce, accessing through web services.
It seems to be a bug in .NET but there's another way to address it by manually editing the wsdl.
More information here:
http://community.salesforce.com/t5/NET-Development/Can-t-update-date-datetime-from-c-webservice-through-enterprise/m-p/96046

Categories