This was the auth setup before the issue was resolved.
HttpTransportProperties.Authenticator basicAuthenticator = new
HttpTransportProperties.Authenticator();
List<String> authSchemes = new ArrayList<String>();
authSchemes.add(Authenticator.BASIC);
basicAuthenticator.setAuthSchemes(authSchemes);
basicAuthenticator.setUsername("admin"); // Set your value
basicAuthenticator.setPassword("admin"); // Set your value
basicAuthenticator.setPreemptiveAuthentication(true);
stub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE,basicAuthenticator);
stub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED,
"false");
ServiceClient service = stub._getServiceClient();
The Issue was with the content type of the HTTP request which was set to
application/soap+xml
Had to set it to application/xml to get the ESB to add the ws security
headers to the request
service.getOptions().setProperty(Constants.Configuration.MESSAGE_TYPE,
HTTPConstants.MEDIA_TYPE_APPLICATION_XML);
Even though the code works now I don't understand why the content type is
an Issue here. What is the reason for this behavior?
On Fri, Dec 6, 2013 at 8:26 AM, Nirmal Fernando <[email protected]> wrote:
> Can you paste the full service client here?
>
>
> On Wed, Dec 4, 2013 at 3:07 PM, Tharindu Perera <[email protected]>wrote:
>
>> Hi all,
>>
>> I'm a WSO2 intern and I'm trying to create a client to a proxy service
>> that is securing an unsecured back-end service. I've set the key store for
>> https communication. If I remove the security provided by the proxy the
>> client manages to access the services via the proxy. But after enabling
>> basic username password security I always get the exception
>>
>> org.apache.axis2.AxisFault: The input stream for an incoming message is
>> null.
>> at
>> org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:92)
>> at
>> org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:67)
>> at
>> org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:354)
>> at
>> org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421)
>> at
>> org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
>> at
>> org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
>> at
>> assignment.clients.OrderProcessorStub1.getPrice(OrderProcessorStub1.java:817)
>>
>> I'm setting the user name password in the client as below
>>
>> HttpTransportProperties.Authenticator basicAuthenticator =new
>> HttpTransportProperties.Authenticator();
>> List<String> authSchemes = new ArrayList<String>();
>> authSchemes.add(Authenticator.BASIC);
>> basicAuthenticator.setAuthSchemes(authSchemes);
>> basicAuthenticator.setUsername("admin");
>> basicAuthenticator.setPassword("admin");
>> basicAuthenticator.setPreemptiveAuthentication(true);
>>
>> stub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE,basicAuthenticator);
>>
>> stub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED,
>> "false");
>>
>> And the ESB does not register the soap messages in the SOAP Message
>> Tracer. What should I add to the service client to authenticate itself?
>>
>> _______________________________________________
>> Dev mailing list
>> [email protected]
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
>
> --
>
> Thanks & regards,
> Nirmal
>
> Senior Software Engineer- Platform Technologies Team, WSO2 Inc.
> Mobile: +94715779733
> Blog: http://nirmalfdo.blogspot.com/
>
>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev