I've recently noticed that using Service References(WCF) causes problems with plain old SOAP API's. I thought that the newer more improved approach was to use Service References because WCF is more flexible and modern. Can anyone detect how I can make this work with WCF in VS2013?
It is a simple console app trying to consume RxNav (free) api
URL: http://mor.nlm.nih.gov/axis/services/RxNormDBService
After adding a "Service Reference" to the solution I entered the following code:
Program.cs
static void Main(string[] args)
{
var client = new RxNavAPI.DBManagerClient();
try
{
var matches = client.getDrugs("aspirin");
foreach (var conceptGroup in matches)
{
foreach (var concept in conceptGroup.rxConcept)
{
Console.WriteLine(String.Format("Name: {0}, Syn: {1}", concept.STR, concept.SY));
}
}
client.close();
}
catch (TimeoutException ex)
{
Console.WriteLine("Timeout occurred while accessing RxNav API");
Console.WriteLine(ex.Message);
throw;
}
}
App.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="RxNormDBServiceSoapBinding" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://mor.nlm.nih.gov/axis/services/RxNormDBService"
binding="basicHttpBinding" bindingConfiguration="RxNormDBServiceSoapBinding"
contract="RxNavAPI.DBManager" name="RxNormDBService" />
</client>
</system.serviceModel>
</configuration>
One thing that I have noticed is when added as a Web Reference the client is called like:
var client = new RxNavAPI.DBManagerService();
while when using Service Reference it is like:
var client = new RxNavAPI.DBManagerClient();
EDIT: The error I am receiving is
System.InvalidOperationException : "RPC Message getProprietaryInformationRequest1 in operation getProprietaryInformation1 has an invalid body name getProprietaryInformation. It must be getProprietaryInformation1"