-
1. Re: Accessing secured ODATA service in Java
rareddy Jul 24, 2014 2:05 PM (in response to teiiduser)This seems like good question to framework that supplied ODataJerseyConsumer class, in this case I guess it is OData4J.
-
2. Re: Accessing secured ODATA service in Java
teiiduser Jul 24, 2014 2:10 PM (in response to rareddy)Yes. OData4j
-
3. Re: Accessing secured ODATA service in Java
shawkins Jul 24, 2014 2:10 PM (in response to rareddy)See https://searchcode.com/codesearch/view/9368038/
//ODataConsumer c = ODataJerseyConsumer.create(endpoint);
OClientBehavior basicAuth = OClientBehaviors.basicAuth("user", "password");
ODataConsumer c = ODataJerseyConsumer.newBuilder(endpoint).setClientBehaviors(basicAuth).build();
-
4. Re: Accessing secured ODATA service in Java
teiiduser Jul 24, 2014 3:10 PM (in response to shawkins)What could be the reason for this runtime exception. Doesnt give much information:
Exception in thread "main" java.lang.RuntimeException: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog
at [row,col {unknown-source}]: [1,0]
at org.odata4j.core.Throwables.propagate(Throwables.java:11)
at org.odata4j.stax2.staximpl.StaxXMLFactoryProvider2$StaxXMLEventReader2.nextEvent(StaxXMLFactoryProvider2.java:113)
at org.odata4j.format.xml.EdmxFormatParser.parseMetadata(EdmxFormatParser.java:55)
at org.odata4j.consumer.AbstractODataClient.getMetadata(AbstractODataClient.java:44)
at org.odata4j.consumer.AbstractODataConsumer$CachedEdmDataServices.refreshDelegate(AbstractODataConsumer.java:212)
at org.odata4j.consumer.AbstractODataConsumer$CachedEdmDataServices.getDelegate(AbstractODataConsumer.java:205)
at org.odata4j.internal.EdmDataServicesDecorator.findEdmEntitySet(EdmDataServicesDecorator.java:46)
at org.odata4j.consumer.AbstractODataConsumer$CachedEdmDataServices.findEdmEntitySet(AbstractODataConsumer.java:221)
at org.odata4j.consumer.AbstractODataConsumer.getFeedCustomizationMapping(AbstractODataConsumer.java:235)
at org.odata4j.consumer.AbstractODataConsumer.getEntity(AbstractODataConsumer.java:99)
at org.odata4j.consumer.AbstractODataConsumer.getEntity(AbstractODataConsumer.java:91)
at org.odata4j.consumer.AbstractODataConsumer.getEntity(AbstractODataConsumer.java:83)
at com.lgc.test.TestReadWrite.run(TestReadWrite.java:36)
at com.lgc.test.TestReadWrite.main(TestReadWrite.java:24)
Caused by: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog
at [row,col {unknown-source}]: [1,0]
at com.ctc.wstx.sr.StreamScanner.throwUnexpectedEOF(StreamScanner.java:677)
at com.ctc.wstx.sr.BasicStreamReader.handleEOF(BasicStreamReader.java:2119)
at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2025)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1117)
at org.codehaus.stax2.ri.Stax2EventReaderImpl.nextEvent(Stax2EventReaderImpl.java:255)
at org.odata4j.stax2.staximpl.StaxXMLFactoryProvider2$StaxXMLEventReader2.nextEvent(StaxXMLFactoryProvider2.java:111)
... 12 more
-
5. Re: Accessing secured ODATA service in Java
shawkins Jul 24, 2014 3:19 PM (in response to teiiduser)If the server is returning a non-xml formatted 401 / unauthorized response, then you could see an exception like that.
-
6. Re: Accessing secured ODATA service in Java
teiiduser Jul 24, 2014 4:19 PM (in response to shawkins)How can I check that extra log information? In the Java console I see only the above error.
Also my service actually needs an extra parameter.. so when I access my service I have to put this in the browser:
http://localhost/mydataserver/dsl.svc/mymodel/1/mymodel-ds?param=value
but the endpoint in my java program is http://localhost/mydataserver/dsl.svc/mymodel/1/mymodel-ds
Would that be causing this problem? How do I pass this parameter?
Also would it matter if the service is using a different type of authentication, for eg: forms based?
-
7. Re: Accessing secured ODATA service in Java
shawkins Jul 24, 2014 4:32 PM (in response to teiiduser)> How can I check that extra log information?
That would be the server log.
> Would that be causing this problem? How do I pass this parameter?
Seems like that would just be part of your endpoint, but if you are thinking something else you should check the jersey docs.
> Also would it matter if the service is using a different type of authentication, for eg: forms based?
Are you talking about a Teiid odata service?
-
8. Re: Accessing secured ODATA service in Java
teiiduser Jul 24, 2014 5:35 PM (in response to shawkins)If you mean the JBOSS server log, it does not show anything regarding this error.
-
9. Re: Accessing secured ODATA service in Java
teiiduser Jul 25, 2014 11:47 AM (in response to teiiduser)Does anyone know the syntax to do form based authentication in java for ODATA service?
-
10. Re: Accessing secured ODATA service in Java
rareddy Jul 26, 2014 1:03 PM (in response to teiiduser)It would be specific to that form as what that form submission target is, and typically you need to execute a POST with form parameter values against the endpoint. As far as Teiid OData is concerned we only support BasicAuth right now OOB.