0 امتیاز
قبل در برنامه نویسی توسط (9 امتیاز)
ویرایش شده قبل توسط

در وایز برای تولید سرویسهای REST از CXF استفاده می شود. در تنظیمات فعلی exception های سرویسهای REST در کجا به JSON تبدیل می شوند؟ می خواهیم که در json خروجی در حالت خطا پیغام را خودمان تولید کنیم. در API سرویس هایمان مهم است.

1 پاسخ

0 امتیاز
قبل توسط (1.2هزار امتیاز)
انتخاب شده قبل توسط
 
بهترین پاسخ

در فایل cxf-servlet.xml نام کلاس Highlight شده را ملاحظه کنید. می توانید کلاس دلخواه خودتان را به جای ApplicationExceptionHandler معرفی کنید.

<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" 
	xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd    
						http://cxf.apache.org/jaxws    http://cxf.apache.org/schemas/jaxws.xsd    
						http://cxf.apache.org/jaxrs    http://cxf.apache.org/schemas/jaxrs.xsd">

	<import resource="classpath:META-INF/cxf/cxf.xml"/>
	<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>

	<jaxrs:server address="/" id="service">
		<jaxrs:serviceBeans>
			<ref bean="restMessageLoaderService"/>
		</jaxrs:serviceBeans>
		<jaxrs:providers>
			<bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider">
				<constructor-arg>
					<bean class="org.codehaus.jackson.map.ObjectMapper">
						<property name="dateFormat">
							<bean class="org.codehaus.jackson.map.util.ISO8601DateFormat"/>
						</property>
					</bean>
				</constructor-arg>
			</bean>
			<bean class="ir.asta.wise.core.datamanagement.exception.ApplicationExceptionHandler"/>
		</jaxrs:providers>
	</jaxrs:server>

</beans>

 

سوالات مشابه

0 امتیاز
1 پاسخ 774 بازدید
0 امتیاز
2 پاسخ 2.4هزار بازدید
0 امتیاز
1 پاسخ 1.9هزار بازدید
0 امتیاز
1 پاسخ 396 بازدید
0 امتیاز
0 پاسخ 538 بازدید
+1 امتیاز
0 پاسخ 932 بازدید
+1 امتیاز
1 پاسخ 889 بازدید
+1 امتیاز
1 پاسخ 595 بازدید
+1 امتیاز
1 پاسخ 205 بازدید
...