calling api added as web reference with wsSecurity and WS-Addressing - wcf

I have to consume client API with WsSecurity(WSS) and WS-Addressing(WSA). while i am consuming API in my app.config endpoint configured like bellow.
i have added it as web reference.
<applicationSettings>
<WCFDemoforVEDA.Properties.Settings>
<setting name="WCFDemoforVEDA_VEDAServiceReference_idmatrix"
serializeAs="String">
<value>https://vedaxml.com/sys2/idmatrix-v4</value>
</setting>
</WCFDemoforVEDA.Properties.Settings>
can you help me out how we can pass there username and password while calling api.

Related

How to add header key to swagger editor in wso2 esb

I want to deploy my rest API to wso2 ESB. I am adding my API URL to the wso2 ESB swagger URL with the header authorization key. But I am not to add a header in the wso2 swagger URL. Here I am sending my code syntax,
Could anybody fix my problem?
<api xmlns="http://ws.apache.org/ns/synapse" name="meter" context="/Ls" hostname="localhost" version="1.0.0.0" version-type="url" publishSwagger="file:http://172.27.100.27:8000>
<resource methods="GET"/>
</api>

How to publish an existing API on WSO2 ESB

I can't seem to find a simple article on how to publish an existing restAPI through WSO2 ESB as proxy.
I have an existing API which responds with either Json or XML output based on content-type on the header. I would like to publish this api through the WSO2 ESB as proxy. I don't think WSO2 Application server is needed in this case, as the rest api is running on its own app server.
API:
http://somehost.com:8001/api/BusinessApi/GetContentTypes
Response:
[{"contentTypeID":1,"name":"Movies","isTop":true,"subLevels":1,"contentTypeIdBase":1},{"contentTypeID":2,"name":"TV Show","isTop":true,"subLevels":3,"contentTypeIdBase":4},{"contentTypeID":3,"name":"TV Season","isTop":false,"subLevels":2,"contentTypeIdBase":4},{"contentTypeID":4,"name":"TV Episode","isTop":false,"subLevels":1,"contentTypeIdBase":4},{"contentTypeID":5,"name":"Music Album","isTop":true,"subLevels":2,"contentTypeIdBase":6},{"contentTypeID":6,"name":"Music Track","isTop":false,"subLevels":1,"contentTypeIdBase":6},{"contentTypeID":7,"name":"Music Video","isTop":false,"subLevels":1,"contentTypeIdBase":7},{"contentTypeID":8,"name":"Book Set","isTop":false,"subLevels":1,"contentTypeIdBase":8},{"contentTypeID":9,"name":"Books","isTop":true,"subLevels":1,"contentTypeIdBase":9}]
The objective is to publish the api via WSO2 ESB and try to achieve the below actions:
Logging the API calls
Messaging/ forking calls based on a criteria
Centralize all API calls authentication model
Is it possible to just run ESB server to achieve this function?
Thanks in Advance!!
Setting up a proxy API, this can only be done via
adding API option under main->service-bus->APIs
Give the API a custom name, which is the identity on WSO2 ESB.
Give the context which is your custom resource.
go to the source view and add the below source
Begin of snippet
<api xmlns="http://ws.apache.org/ns/synapse" name="GetC" context="/api1">
<resource methods="GET" url-mapping="/">
<inSequence>
<log/>
<send>
<endpoint>
<address uri="http://somehost.com:8001/api/businessApi/GetContentTypes"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<log/>
<send/>
</outSequence>
</resource>
</api>
End of snippet
You should now be to access the api via ESB proxy url
With your approach, you have created an api in ESB, which passes the request to your backend api. During this you expect to log every api call and control authentication too. I didn't understand the forking requirement.
Have you tried WSO2 API Manager? It will allow you to make your api a managed api. i.e. You will be able to control access to your api via oauth tokens. You can log the api calls too (although its not a good thing to log every call due to performance reasons).
If you integrate it with WSO2 DAS, you will be able to see some useful stats too. This is the API Manager documentation.
https://docs.wso2.com/display/AM1100/WSO2+API+Manager+Documentation

HTTP method for a WCF Restful Service

Can anybody tell me how do I give the HTTP method of the WCF RestFul service created by BizTalk Publishing wizard.The WCF service created for the schema is having three elements
I am trying to give in different ways but every time I am getting the new error when I am trying to browse them throw the browser.
<BtsHttpUrlMapping>
<Operation Name="RESTServices.REST.lims" Method = "GET" Url ="/username={username}&pass={pass}&specimen={specimen}" />
</BtsHttpUrlMapping>
<BtsHttpUrlMapping>
<Operation Name="RESTServices.REST.lims" Method = "GET" Url ="/username={username}/pass={pass}/specimen={specimen}" />
</BtsHttpUrlMapping>
Can anybody please let me know how do I give the HTTP method and access the WCF service created.

autofac wcf integration have /basic at the end of the soap address

We had an old wcf service not using Autofac. The wsdl generated from it looks like this
<wsdl:service name="WebSite.Service.WebSiteService">
<wsdl:port name="BasicHttpBinding_IWebSiteService" binding="tns:BasicHttpBinding_IWebSiteService">
<soap:address location="http://localhost/WebSiteService.svc/basic"/>
</wsdl:port>
</wsdl:service>
However the new webservice I created with autofac wcf integration(did it following the example from autofac wcf webpage) doesn't have the word basic at the end of the soap address url (as in ...localhost/WebSiteService.svc/basic). It is causing some old mobile application and websites failing... I was just wondering if anyone know how I can get the word basic appearing in the soap address section?
Thanks

Configuring Membership Provider with credentials setup in web.config

I'm trying to implement Forms Authentication in ASP.NET MVC4 application and I've only one user who is going to get authenticated to do some admin activities.
<authentication mode="Forms">
<forms timeout="2880" loginUrl="~/Admin/Login" slidingExpiration="true">
<credentials passwordFormat="Clear">
<user name="user" password="password"/>
</credentials>
</forms>
</authentication>
When I try to use the FormsAuthentication.ValidateUser method I get an obsolete warning and I'm supposed to use now Membership class.
My question is how I can configure membership provider in web.config to use the credentials setup in the web.config? What provider I should specify in the name attribute?
Unfortunately, there is no built-in membership provider for the mechanism of storing the credentials in the web.config as you describe. You could write your own to invoke the FormsAuthentication.Authenticate method or call this from your own custom login control's code-behind.