Oracle application server HTTP error 401 authorization required axis2 - axis2

I have a jsp application deployed on OAS server 10.1.2.0.2. The problem which I have is that only sometimes the application cannot invoked web service method. The error which I get is :
16:58:52,332 INFO HTTPSender:202 - Unable to sendViaPost to url[http://prodbus.farm.globul.bg:8000/BPACommunicationWS/BPACommunicationWS]
org.apache.axis2.AxisFault: Transport error: 401 Error: Authorization Required
at org.apache.axis2.transport.http.HTTPSender.handleResponse(HTTPSender.java:310)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:200)
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:76)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:400)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:225)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:435)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:402)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
The problem is fixed after restart the OC4J instance. Also the allocation of the memory is growing a lot.
Does somebody know the reason of this? I used axis version 1.5.1.
Thanks in advance.

The problem was that I use axis2 for a web service with authorization in ClassOne and in ClassTwo I use axis2 without authoiztion and somehow when I make the authorization in ClassOne axis2 remember that there is a authorization and do it in ClassTwo.
I remove also the set preemptive flag and everything works fine.

Related

Failure response with status "201" and error message "Created" When invoking WLAuthorizationManager.obtainAccessToken

Environment:
Windows Server 2012 R2
JRE 1.8.0_101
IBM WAS Liberty Core 8.5.5.5
IBM MFP 8.1
Apache Web server
We have set up the UAT with the above environment. We have deployed our application on the server, have deployed adapter for user authentication and a resource adapter to fetch the data.
When we invoke an adapter procedure without security (unprotected) the app is fetching the data. But when we try to invoke an adapter procedure with default scope or with a custom scope Instead of triggering the challenge handler, we are getting failure response with error status ‘201’ and error message ‘Created’.
Another observation is that, when the WLAuthorizationManager.ObtainAccessToken is invoked with default scope or with push.mobileclient, it is giving the same failure response with error status ‘201’ and error message ‘Created’. The same application works fine in the development environment.
When I try to obtain a token from postman using https://domain:port/mfp/api/az/v1/token and pass the scope, grant_type and the necessary authorization header, it is providing the valid response with token. But from the app when we try by obtain token it is given failure response.
Failure response
{"status":201,"statusText":"Created","responseText":"","responseHeaders":{"connection":"Keep-Alive","content-language":"en-US","content-length":"0","date":"Fri, 17 May 2019 05:42:45 GMT","keep-alive":"timeout=5, max=100","location":"/mfp/api/registration/clients/1e746550-e804-4ee7-88ba-b99896qqqqpwo","server":"Apache/2.4.39 (Win64) OpenSSL/1.1.1b","via":"1.1 ","x-powered-by":"Servlet/3.0"},"errorMsg":"Created","errorCode":"201"}
201 is not a response code that is expected from the /token endpoint. This is very likely coming from an intermediate element in your topology. You've mentioned about the Apache Web Server as part of the configuration - is this sending the 201 ?
Moreover, the actual response from the server shows "server":"Apache/2.4.39 (Win64) OpenSSL/1.1.1b"
So, here is what you can do
a. Try bypassing the web server and see if resolves the issue - in all likeliness, it should.
b. Validate the configuration settings of the Apache Web server to see why the 201 is being returned.
Late to the party, but for anyone that is still running into this error:
Install the following interim fix: 8.0.0.0-MFPF-IF202006151151
This solved the error for me. Seems to be a bug in MobileFirst, took me ages to find.

invoke web service with authentication headers in ode bpel

I'm using eclipse bpel designer and trying to invoke a external service which requires authentication headers to be passed.
Here is what I have done
1. Created a headers.endpoint file with the following content
*alias.sample_ns="http://sample.com"
sample_ns.serviceName.portName.ode.http.default-headers.username=system
sample_ns.serviceName.portName.ode.http.default-headers.password=admin*
Placed it in ..\webapps\ode\WEB-INF\processes\$process folder
When I invoke the service I'm getting the following error
"Error sending message (mex={PartnerRoleMex#hqejbhcnphrckf492s9n9b [PID {http://createReservation}CreateReservation-1541] calling org.apache.ode.bpel.epr.WSAEndpoint#1e1f4b8.saveRecord(...) Status ASYNC}): Transport error: 401 Error: Unautho".
I think I need to add header information when invoking the service in BPEL process as well. But couldn't find the way to do it. How can it be done, if this is actually what I'm missing? Or is there something else to be done?
Thanks in advance
Note: HTTP Auth information cannot be set in the *.endpoint files.
For invoking HTTP Service
Testcase will show you how to do it
https://github.com/apache/ode/tree/ode-1.3.x/axis2-war/src/test/resources/TestEndpointProperties
Add message part in WSDL as shown here
https://github.com/apache/ode/blob/ode-1.3.x/axis2-war/src/test/resources/TestEndpointProperties/Echo.wsdl#L66
Assign credentials in Process
https://github.com/apache/ode/blob/ode-1.3.x/axis2-war/src/test/resources/TestEndpointProperties/test-endpoint-properties.bpel#L73
For invoking Soap Service
http://ode.apache.org/http-authentication.html

Spring-SAML Authentication Failed: HttpSession returned null object for SPRING_SECURITY_CONTEXT

I'm using spring-saml2-sample app to connect to a Shibboleth IDP. I finally managed to send the correct saml request to the IDP using http post, but after login I get back the following on the SP side:
org.springframework.security.web.context.HttpSessionSecurityContextRepository - HttpSession returned null object for SPRING_SECURITY_CONTEXT
There was a post like this one where the problem was resolved by moving to spring security version 3.1.2, but that is the version that comes with the saml2-sample app.
Am I missing something? I haven't changed much in the saml2-sample app, the web.xml is the same, libs are the same.
Any help will be very appreciated.

WCF Server Error. The content type text/html of the response message does not match the content type of the binding

I've got a WCF Service, which calls a webservice, running on my development IIS server (IIS 7). I've added it as a service reference to a C# Website Project and it adds fine.
However, when I try to call any of the service contracts, I get the following error:
The content type text/html
of the response message does not match
the content type of the binding
(text/xml; charset=utf-8). If using a
custom encoder, be sure that the
IsContentTypeSupported method is
implemented properly. The first 1024
bytes of the response were:
'Blocked Web
Page
thanks in advance
BB
The error message says it clearly: you're getting back an HTML page instead of your service response. Looking at the fragment of that page listed in the error message, you're probably not authroized to use that service.
Try to connect to the service URL in a browser - you should probably see a page explaining that you're not allowed to access the page. Most likely, this is a permissions issue.
You need to configure WCF Tracing and find out what's happening on the server side.

WCF Service - The resource cannot be found

I am deployed my published the WCF web service to my server and when i am tryihg to
access it its giving me following error????
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /API/Errors/GeneralError.aspx
It was an application pool issue, on recycling the application pool the issue got resolved.
I would say it has to do with the handlers setup in IIS...
read this http://bloggingabout.net/blogs/jpsmit/archive/2007/01/17/wcf-http-404-when-hosted-in-iis.aspx