Extension calling a WebService fails to find the Endpoint

Extension calling a WebService fails to find the Endpoint

  
I have to create an Extension in Integration Studio to call a complex WebService.
I created a new extension and stubbed in an Action with a couple of inputs and outputs.
Using Visual Studio I have incorporated the appropriate C# code to call the WebService.
I created an app.config which has the proper endpoint.
I created a test app in Service Studio  which references the Extension I created.
When I run it it comes back with:

Could not find default endpoint element that references contract 'OutSystems.NssMyProject.MyService' 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.

I can run the C# code in a stand alone C# Windows Form and it works fine.
It acts like OutSystems isn't reading the app.config file.

Any ideas???

Thanks.
 

Hi Jeff,

I just want to remind you that when you build an extension, it generates a DLL to be linked by the web-application. The "app.config" file you have in your Visual Studio application won't be copied to the web-application directory (to be read). The only config file read by default in a web-application is the "web.config" and it is not affected by your extension config file. There is a way to change web.config file using Service Center Factory Configuration but this is configured at eSpace level, not extension level.

I advise you to convert your "app.config" file into C# code so it can be called inside the action. This way you control what is really configured.


Regards,
João Portela
I am new to C# and .NET.
I have been trying to figure out how to set the endpoint within the code, but have been unsuccessful.
How can I get my app.config into my code as you suggest?

Thanks,
Jeff
Here is the appconfig I need to use to set the endpoints.
How do I set these in the CS code?

<?xml version="1.0" encoding="utf-8"?>

<configuration>

<system.serviceModel>

<bindings>

<basicHttpBinding>

<binding name="InquiryServiceSoapBinding">

<readerQuotas maxStringContentLength="2000000" maxNameTableCharCount="2147483647"/>

<security mode="TransportWithMessageCredential"/>

</binding>

</basicHttpBinding>

</bindings>

<client>

<endpoint address=https://mydomain.com/Inquiry.svc

binding="basicHttpBinding" bindingConfiguration="InquiryServiceSoapBinding"

contract="OutSystems.NssMyExtension.InquiryService"

name="InquiryServiceSoap" />

</client>

</system.serviceModel>

</configuration>


Here is my trimmed down CS code.

using System;

using System.Collections;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.ServiceModel;

using System.ServiceModel.Configuration;

using System.Web.Configuration;

using System.Data;

using OutSystems.HubEdition.RuntimePlatform;

using GotDotNet.ApplicationBlocks;

namespace OutSystems.NssMyExtension  {

public class CssMyExtension: IssMyExtension  {

private const string _USERNAME = "user";

private const string _PASSWORD = "password";

/// <summary>

///

/// </summary>

/// <param name="ssAcctId"></param>

/// <param name="ssAcctType"></param>

/// <param name="ssCurrBal"></param>

/// <param name="ssAvailBal"></param>

public void MssAcctInq(string ssAcctId, string ssAcctType, out string ssCurrBal, out string ssAvailBal) {

ssCurrBal = string.Empty;

ssAvailBal = string.Empty;

// TODO: Write implementation for action

InquiryServiceClient proxy = new InquiryServiceClient();

AcctInqRequest request = new AcctInqRequest();

AcctInqResponse response = new AcctInqResponse();

request.MsgRqHdr = new MsgRqHdr_CType();

request.MsgRqHdr.subHdr = new subHdr_CType();

request.MsgRqHdr.subHdr.AuditUsrId = "Test";

request.MsgRqHdr.subHdr.AuditWsId = "Test";

request.InAcctId = new AccountId_CType();

request.InAcctId.AcctId = new AcctId_Type();

request.InAcctId.AcctType = new AcctType_Type();

request.InAcctId.AcctId.Value = ssAcctId;

request.InAcctId.AcctType.Value = ssAcctType;

proxy.ClientCredentials.UserName.UserName = _USERNAME;

proxy.ClientCredentials.UserName.Password = _PASSWORD;

 

response = proxy.AcctInq(request);

ssCurrBal = response.CurBal.ToString();

ssAvailBal = response.AvlBal.ToString();

} // MssAcctInq

} // CssMyExtension

} // OutSystems.NssMyExtension

Hi Jeff,

In your extension - or, in your .Net application - is it you who explicitly read the App.config values? Can you share that code as well - or, the entire main extension code, so we can take a look into it?

Regards,

Paulo Tavares

Paulo, the code has sensitive client info, so I can not divuldge more than I have.
As a temporary work around I have added the ServiceModel portion of the app.config to the eSpace web.config.
I know this is a bad way since the web.config is replaced each time the eSpace is republished.
So I need to either put this in the C# CS code, of some how be able to reference a static config file on the server.
I prefer to not use the machine.config.
What do you recommend?  And how best would I impliment your recommendation?

Thanks,
Jeff
 

Hi Jeff,

The easiest way to do this is to set the necessary configurations in code as follows:

            BasicHttpBinding binding = new BasicHttpBinding();
            binding.ReaderQuotas.MaxStringContentLength = 2000000;
            binding.ReaderQuotas.MaxNameTableCharCount = 2147483647;
            binding.Security.Mode = BasicHttpSecurityMode.TransportWithMessageCredential;
            EndpointAddress endpoint = new EndpointAddress("https://mydomain.com/Inquiry.svc");
            InquiryServiceClient proxy = new InquiryServiceClient(binding, endpoint);

This should do the trick.

Regards,
João Neves
Very nice Joao!
I think this is exactly what I needed.
So far it seems to do what I need.

Thanks,
Jeff