Here is a WADL fragment:
<resource path="finTrns">
<method name="POST" id="post">
<request>
<representation xmlns:fbl="
http://example.com/fbl/core
" mediaType="application/xml" element="fbl:finTrn"/>
</request>
</method>
</resource>
and the corresponding java:
public static class FinTrns {
private JAXBDispatcher _jaxbDispatcher;
private DSDispatcher _dsDispatcher;
private UriBuilder _uriBuilder;
private JAXBContext _jc;
private HashMap<String, Object>
_templateAndMatrixParameterValues;
/**
* Create new instance
*
*/
public FinTrns()
throws JAXBException
{
_jc = JAXBContext.newInstance("com.example.fbl.client");
_jaxbDispatcher = new JAXBDispatcher(_jc);
_dsDispatcher = new DSDispatcher();
_uriBuilder = new UriBuilder();
List<String> _matrixParamSet;
_matrixParamSet = _uriBuilder.addPathSegment("
http://localhost:9877/
");
_matrixParamSet = _uriBuilder.addPathSegment("finTrns");
_templateAndMatrixParameterValues = new HashMap<String,
Object>();
}
public void post(DataSource input)
throws IOException, MalformedURLException
{
HashMap<String, Object> _queryParameterValues = new
HashMap<String, Object>();
HashMap<String, Object> _headerParameterValues = new
HashMap<String, Object>();
String _url =
_uriBuilder.buildUri(_templateAndMatrixParameterValues,
_queryParameterValues);
DataSource _retVal = _dsDispatcher.doPOST(input,
"application/xml", _url, _headerParameterValues, null);
return ;
}
public void postAsvoid(FinTrn input)
throws IOException, MalformedURLException, JAXBException
{
HashMap<String, Object> _queryParameterValues = new
HashMap<String, Object>();
HashMap<String, Object> _headerParameterValues = new
HashMap<String, Object>();
String _url =
_uriBuilder.buildUri(_templateAndMatrixParameterValues,
_queryParameterValues);
Object _retVal = _jaxbDispatcher.doPOST(input,
"application/xml", _url, _headerParameterValues, null);
if (_retVal == null) {
return ;
}
if (JAXBElement.class.isInstance(_retVal)) {
JAXBElement jaxbElement = ((JAXBElement) _retVal);
_retVal = jaxbElement.getValue();
}
return ;
}
}
On May 14, 2009, at 1:03 PM, Marc Hadley wrote:
> Could you send the WADL file and the generated Endpoint.java source.
> I think there may be a straightforward fix but need those to verify.
>
> Thanks,
> Marc.
>
> On May 14, 2009, at 1:46 PM, Guillaume Lebleu wrote:
>
>> I have a method in my client Endpoint.java that takes a JAXB object
>> in, and returns void (resource creation via HTTP POST).
>>
>> In my resource server implementation, I return a Response via
>> Response.created(someresourcelocation).build();
>>
>> This results in the exception below. My only workaround so far is
>> to echo the JAXB in the POST response via
>> Response.created(...).entity(...).build(), but I'd like to avoid
>> doing so.
>>
>> Thank you in advance,
>>
>> Guillaume
>>
>> ---
>>
>> javax.xml.bind.UnmarshalException
>> - with linked exception:
>> [org.xml.sax.SAXParseException: Premature end of file.]
>> at
>> javax
>> .xml
>> .bind
>> .helpers
>> .AbstractUnmarshallerImpl
>> .createUnmarshalException(AbstractUnmarshallerImpl.java:315)
>> at
>> com
>> .sun
>> .xml
>> .bind
>> .v2
>> .runtime
>> .unmarshaller
>> .UnmarshallerImpl.createUnmarshalException(UnmarshallerImpl.java:514)
>> at
>> com
>> .sun
>> .xml
>> .bind
>> .v2
>> .runtime
>> .unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:215)
>> at
>> com
>> .sun
>> .xml
>> .bind
>> .v2
>> .runtime
>> .unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:184)
>> at
>> javax
>> .xml
>> .bind
>> .helpers
>> .AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:
>> 137)
>> at
>> javax
>> .xml
>> .bind
>> .helpers
>> .AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:
>> 184)
>> at
>> org.jvnet.ws.wadl.util.JAXBDispatcher.doPOST(JAXBDispatcher.java:158)
>> at com.example.fbl.client.Endpoint
>> $FinTrns.postAsvoid(Endpoint.java:338)
>> at
>> com
>> .example
>> .fbl.client.tests.TestEndpoint.testPostFinTrn(TestEndpoint.java:63)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> sun
>> .reflect
>> .NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>> at
>> sun
>> .reflect
>> .DelegatingMethodAccessorImpl
>> .invoke(DelegatingMethodAccessorImpl.java:25)
>> at java.lang.reflect.Method.invoke(Method.java:585)
>> at junit.framework.TestCase.runTest(TestCase.java:168)
>> at junit.framework.TestCase.runBare(TestCase.java:134)
>> at junit.framework.TestResult$1.protect(TestResult.java:110)
>> at junit.framework.TestResult.runProtected(TestResult.java:128)
>> at junit.framework.TestResult.run(TestResult.java:113)
>> at junit.framework.TestCase.run(TestCase.java:124)
>> at junit.framework.TestSuite.runTest(TestSuite.java:232)
>> at junit.framework.TestSuite.run(TestSuite.java:227)
>> at
>> org
>> .junit
>> .internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:91)
>> at
>> org
>> .eclipse
>> .jdt
>> .internal
>> .junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
>> at
>> org
>> .eclipse
>> .jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>> at
>> org
>> .eclipse
>> .jdt
>> .internal
>> .junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
>> at
>> org
>> .eclipse
>> .jdt
>> .internal
>> .junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
>> at
>> org
>> .eclipse
>> .jdt
>> .internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:
>> 386)
>> at
>> org
>> .eclipse
>> .jdt
>> .internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:
>> 196)
>> Caused by: org.xml.sax.SAXParseException: Premature end of file.
>> at
>> com
>> .sun
>> .org
>> .apache
>> .xerces
>> .internal
>> .util
>> .ErrorHandlerWrapper
>> .createSAXParseException(ErrorHandlerWrapper.java:236)
>> at
>> com
>> .sun
>> .org
>> .apache
>> .xerces
>> .internal
>> .util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:215)
>> at
>> com
>> .sun
>> .org
>> .apache
>> .xerces
>> .internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:
>> 386)
>> at
>> com
>> .sun
>> .org
>> .apache
>> .xerces
>> .internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:
>> 316)
>> at
>> com
>> .sun
>> .org
>> .apache
>> .xerces
>> .internal
>> .impl
>> .XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:230)
>> at
>> com
>> .sun
>> .org
>> .apache
>> .xerces
>> .internal.parsers.XML11Configuration.parse(XML11Configuration.java:
>> 798)
>> at
>> com
>> .sun
>> .org
>> .apache
>> .xerces
>> .internal.parsers.XML11Configuration.parse(XML11Configuration.java:
>> 764)
>> at
>> com
>> .sun
>> .org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:
>> 148)
>> at
>> com
>> .sun
>> .org
>> .apache
>> .xerces
>> .internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:
>> 1242)
>> at
>> com
>> .sun
>> .xml
>> .bind
>> .v2
>> .runtime
>> .unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:211)
>> ... 25 more
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_wadl.dev.java.net
>> For additional commands, e-mail: users-help_at_wadl.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_wadl.dev.java.net
> For additional commands, e-mail: users-help_at_wadl.dev.java.net
>