I'm setting up a Django application on IIS with boto3. I got the application running however I'm unable to query any data from AWS due to no profile configuration being detected.
I tried running the application as a service account with AWS permissions. Giving the account R/W permissions to folder.
Adding AWSProfileName and AWSProfilesLocation to web.config file
I have double checked all common issues regarding this error, however, I think that my configuration might be wrong (perhaps in the web.config file)
Web.Config file:
<add key="AWSProfileName" value="Name_of_profile"/>
<add key="AWSProfilesLocation" value="Path_to_credentials_folder"/>
The error I'm getting: The config profile (Profile_Name) could not be found
So I have figured this out.
In my code I was using session to connect to AWS
Session(Name_of_role).
The parameter should be empty:
Session()
In the web.config file:
<add key="AWSProfileName" value="aws-dev"/>
<add key="AWS_ACCESS_KEY_ID" value=""/>
<add key="aws_secret_access_key" value=""/>
<add key="aws_session_token" value=""/>
<add key="AWS_DEFAULT_REGION" value="us-east-1" />
What happened?
Python is using environmental variables through wfastcgi which means that it takes environmental variables from the web.config file under <appSettings> tag. The necessary configuration that I had to use was under boto3 documentation.
I would like to know if there is a way to maintain certain custom configuration values in a .properties file (in Java) and load the properties at ESB startup and use the custom property values within a mediation flow? any ideas on this would be really helpful.
This might be what you are looking for:
https://dzone.com/articles/retrieve-values-xml-config (page dated ~2013)
It shows how you can have a file in the WSO2 registry and read it in your proxy.
(the file stored in the registry can contain your properties)
I would agree with the suggestion to save the properties in an XML file which you then upload to your registry, independent of the code.
That way, the properties can be updated or deleted without having to touch the code.
If you are constrained to use Java .properties files, then it might be advisable to create a JAR that is deployed as a library, which you then call from your ESB sequence.
For a similar use case, we had a custom configuration values / parameters or constants into a global_parameter.xml file and have it managed in a governance registry (decide based on your stack).
For example, the global_parameter.xml can be like the following.
<custom>
<Version>2.3</Version>
<Type>FOR</Type>
</custom>
We can load the parameters through a sequence and then use the parameters by reusing the sequence file.
<sequence xmlns="http://ws.apache.org/ns/synapse" name="loadProperties_seq">
<property xmlns:ns="http://org.apache.synapse/xsd" name="localProperties" expression="get-property('registry', 'gov:/common/utils/properties/global_parameter.xml')" scope="default" type="OM"/>
</sequence>
Refer the properties..
<property name="url_reg" expression="//custom/Version"/>
<property name="user_reg" expression="//constants/Type"/>
I am developing a Web service using Apache CXF and contract first approach with schema validation. Problem is, that validation is not working. There is no error, so it like is not activated. But validation is configured.
So, I have took a look to official Apache CXF examples you can find here.
I took a look to wsdl_first example and modify it adding schema validation and some restriction in WSDL:
<!-- HTTP Endpoint -->
<jaxws:endpoint xmlns:customer="http://customerservice.example.com/"
id="CustomerServiceHTTP" address="http://localhost:9090/CustomerServicePort"
serviceName="customer:CustomerServiceService" endpointName="customer:CustomerServiceEndpoint"
implementor="com.example.customerservice.server.CustomerServiceImpl">
<jaxws:features>
<bean class="org.apache.cxf.feature.LoggingFeature" />
</jaxws:features>
<!-- schema validation-->
<jaxws:properties>
<entry key="schema-validation-enabled" value="true" />
</jaxws:properties>
</jaxws:endpoint>
To my surprise, it doesn't work either.
OK, so I took a look to wsdl_first_xmlbeans example, where according with the README.txt file, it also shows how CXF configuration can be used to enable schema validation.
And for this example, schema validation works. The difference between both examples is that the second one use JAX-WS APIs and with the XMLBeans approach. Does it have something to do? Why schema validation is not working for first example? Probably, I am missing something.
For validation on the service side, it would likely need to have a wsdlLocation attribute set on the jaxws:endpoint so it would load the WSDL (that would then contain the schemas). Currently, the validation in that example is on the client side only. If you run the service, the log shows:
INFO: Creating Service {http://server.customerservice.example.com/}CustomerServiceImplService from class com.example.customerservice.CustomerService
which shows it's not using the WSDL at all.
I want to use method interceptors in spring 3 to accomplish logging in my app, so that I can trace which methods are called thru the app.
Is there a tutorial (or suggestion) on how to use method interceptors for logging in spring?
It would seem like something that has been done numerous times, but I have not been able to find much data on it.
The Spring reference has a whole chapter on Spring AOP that serves as a very detailed guide for doing what you're looking for. Try that, and if you have some more specific questions, ask.
Spring's org.springframework.aop.interceptor.CustomizableTraceInterceptor lets you achieve this out of the box.
You can customize the interceptor to your need to log argument and returned value of a method.
Example:-
<aop:config>
<aop:advisor advice-ref="loggingAdvisor"
pointcut="execution(public * com.x.y.z.AbstractCommand.*(..))" />
</aop:config>
<bean id="loggingAdvisor"
class="org.springframework.aop.interceptor.CustomizableTraceInterceptor">
<property name="loggerName" value="logger-name" />
<property name="enterMessage" value="Entering $[methodName]($[arguments])" />
<property name="exitMessage" value="Leaving $[methodName](): $[returnValue]" />
</bean>
Spring Document
Similiar SOF question answered
EDIT:
After I modified the web.config and I don't get error that's good.... then I add a new page (html) and write this small code to consume the service like this:
$("#btn12").click(function (event) {
$.getJSON('http://localhost:3576/MyService.svc/GetCurrentUser', {},
function (data) {
alert(data);
});
//return false;
});
I see the following error in my FireBug:
http://localhost:3576/MyService.svc/GetCurrentUser
400 Bad Request
Note: I have added html page on the same wcf project and running the project it self so I am assuming the service is also running ...
What might be wrong here?
END EDIT
I have just created a new wcf services and when I hit f5 from VS and I get this error in WCF Test Client window :
Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata.
Error: Cannot obtain Metadata from http://localhost:3696/MobileService.svc If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.
WS-Metadata Exchange Error
URI: http://localhost:3696/MyService.svc
Metadata contains a reference that cannot be resolved: 'http://localhost:3696/MyService.svc'.
There was no endpoint listening at http://localhost:3696/MyService.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
Unable to connect to the remote server
No connection could be made because the target machine actively refused it 127.0.0.1:3696
HTTP GET Error
URI: http://localhost:3696/MyService.svc
There was an error downloading 'http://localhost:3696/MyService.svc'.
Unable to connect to the remote server
No connection could be made because the target machine actively refused it 127.0.0.1:3696
My config:
<behaviors>
<endpointBehaviors>
<behavior name="MyService.MyService">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="metadataBehavior">
<serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:2812/MyService.svc" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="MyService.MyService"
behaviorConfiguration="metadataBehavior">
<endpoint
address="http://localhost/MyService.svc"
binding="customBinding"
bindingConfiguration="jsonpBinding"
behaviorConfiguration="MyService.MyService"
contract="MyService.IMyService"/>
</service>
</services>
<bindings>
<customBinding>
<binding name="jsonpBinding">
<jsonpMessageEncoding/>
<httpTransport manualAddressing="true"/>
</binding>
</customBinding>
</bindings>
<extensions>
<bindingElementExtensions>
<add name="jsonpMessageEncoding" type="Microsoft.Ajax.Samples.JsonpBindingExtension, MyService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
</bindingElementExtensions>
</extensions>
You need to add a metadata exchange (mex) endpoint to your service:
<services>
<service name="MyService.MyService" behaviorConfiguration="metadataBehavior">
<endpoint
address="http://localhost/MyService.svc"
binding="customBinding" bindingConfiguration="jsonpBinding"
behaviorConfiguration="MyService.MyService"
contract="MyService.IMyService"/>
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"/>
</service>
</services>
Now, you should be able to get metadata for your service
Update: ok, so you're just launching this from Visual Studio - in that case, it will be hosted in Cassini, the built-in web server. That beast however only supports HTTP - you're not using that protocol in your binding...
Also, since you're hosting this in Cassini, the address of your service will be dictated by Cassini - you don't get to define anything.
So my suggestion would be:
try to use http binding (just now for testing)
get this to work
once you know it works, change it to your custom binding and host it in IIS
So I would change the config to:
<behaviors>
<serviceBehaviors>
<behavior name="metadataBehavior">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="MyService.MyService" behaviorConfiguration="metadataBehavior">
<endpoint
address="" <!-- don't put anything here - Cassini will determine address -->
binding="basicHttpBinding"
contract="MyService.IMyService"/>
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"/>
</service>
</services>
Once you have that, try to do a View in Browser on your SVC file in your Visual Studio solution - if that doesn't work, you still have a major problem of some sort.
If it works - now you can press F5 in VS and your service should come up, and using the WCF Test Client app, you should be able to get your service metadata from a) the address that Cassini started your service on, or b) the mex address (Cassini's address + /mex)
In case you rename the svc file make sure that your markup is correct.
You'll need to modify the default configuration and follow these steps:
1) Go to SVC file right click and select view markup
2) Make sure that that code behind and service pointing to correct the file and class name.
FYI - YOU CAN also get this error from a machine that is not having enough memory free. I got this error on a machine I run with 16 gigs of memory. I had a VM running with 6 gigs and a LOT of memory intensive apps. Close some down and this problem went away.
I still did get the error in the title of the question of
Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata.`
I did notice a larger message about memory though in using the WCF Test Client.
Hope this helps someone else.
In my case I was getting this error because the option (HttpActivation) was not enabled.
Add Serializable() before the type you expose
Serializable()
Public Class YourType
Put Serializable into <>
if working with .NET 4.0 WCF service - make sure Global.asax is not in the source directory. If it is , it is picked up at runtime and attempted to be compiled in...
changing the Binding Type from wsHttpbinding to basichttp binding in the endpoint tag and from wsHttpbinding to mexhttpbinginding in metadata endpoint tag helped to overcome the error. Thank you...
In my case, on commenting out the
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
in the web.config file was throwing "Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata".
For me the issue got resolved by doing the following:
Navigated to Tool --> Options --> Project and Solutions --> Web Projects
I could find the first check box "Use the 64 bit version of IIS Express of web sites and projects" was unchecked.
Selecting this check box helped me in launching the WCF Client.
VS Version : VS2019
I observed that when I removed SessionMode from the ServiceContract attribute, the issue went away.
Example:
[ServiceContract(SessionMode=SessionMode.Required, CallbackContract=typeof(ICallbacks))]
public interface IStringReverser
{
[OperationContract]
string ReverseString(string value);
}
to...
[ServiceContract()]
public interface IStringReverser
{
[OperationContract]
string ReverseString(string value);
}
I have tried several solutions mentioned over web, unfortunately without any success.
In my project, I have two interfaces(xml/json) for each service. Adding mex endpoints or binding configurations did not helped at all.
But, I have noticed, I get this error only when running project with *.svc.cs or *.config file focused. When I run project with IService.cs file focused (where interfaces are defined), service is added without any errors. This is really strange and in my opinion conclusion is bug in Visual Studio 2013.
I reproduced same behaviour on several machines(even on Windows Server machine).
Hope this helps someone.
Most of the time this happens due to less memory space. first check then try some other tricks .
The property IsOneWay=true may be true in the Operational contract of the interface.
Remove that property to get rid of this error.
In my case, the Webservice was generating the assembly with a different name than the project/service name. It was set like that by my predecessor developer working on the solution and I didn't know.
It was set to -
<serviceBehaviors>
<behavior name="CustomServiceBehavior">
<serviceAuthorization serviceAuthorizationManagerType="BookingService.KeyAuthorizationManager, BookingService" />
</behavior>
</serviceBehaviors>
So, the fix was the put the right assembly name in serviceAuthorizationManagerType. The assembly name can be obtained from following path of the service project:
Right click on the WCF svc project--> Select "Properties" --> From the list of tabs select "Application". Check the value against "Assembly name:" field in the list. This is the assemblyName to use for serviceAuthorizationManagerType which may not be the servicename necessarily.
<serviceBehaviors>
<behavior name="MyCustomServiceBehavior">
<serviceAuthorization serviceAuthorizationManagerType="BookingService.KeyAuthorizationManager, AssemblyNameFromSvcProperties" />
</behavior>
</serviceBehaviors>
remember to follow the instruction for serviceAuthorizationManagerType as mentioned on https://learn.microsoft.com/en-us/dotnet/framework/wcf/extending/how-to-create-a-custom-authorization-manager-for-a-service
It says -
Warning
Note that when you specify the serviceAuthorizationManagerType, the string must contain the fully qualified type name. a comma, and the name of the assembly in which the type is defined. If you leave out the assembly name, WCF will attempt to load the type from System.ServiceModel.dll.
Change to older Visual Studio.
Weird solution that worked for me.
I was using Visual studio 2017,
after changing to Visual Studio 2015 ,everything worked.
In Visual Studio:
project properties (right click on your project)
Debug -> Start Options
Make sure "Command line arguments" is empty
After Add this to your web.config file and configure according to your service name and contract name.
<behaviors>
<serviceBehaviors>
<behavior name="metadataBehavior">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="MyService.MyService" behaviorConfiguration="metadataBehavior">
<endpoint
address="" <!-- don't put anything here - Cassini will determine address -->
binding="basicHttpBinding"
contract="MyService.IMyService"/>
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"/>
</service>
</services>
Please add this in your Service.svc
using System.ServiceModel.Description;
Hope it will helps you.
I had that issue. The solution is to startup VS with administrative privilege.