私はCXFフレームワークを使用してJAX-RS Webサービスを開発しましたが、私はJboss6にデプロイしました。私は私のHTMLページから、次のURL http://localhost:8080/UPCServiceLayer/services/upcLineOfBusiness/createを使用してアプリケーションにアクセスしようとしますが 私はCXF-RS throwing一致するリクエストパス/作成が見つかりません
No operation matching request path /create is found,
次のサーバーコンソールで次のエラーを取得しています(唯一のPOSTメソッドを使用して)私のcxf.xmlある
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.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-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<import resource="classpath:../upc-spring-dao.xml" />
<jaxrs:server id="upcLineOfBusinessRestServiceServer" address="/upcLineOfBusiness">
<jaxrs:serviceBeans>
<ref bean="upcLineOfBusinessRestService" />
</jaxrs:serviceBeans>
</jaxrs:server>
<bean id="upcLineOfBusinessRestService"
class="com.tecnotree.upc.services.restservices.impl.UpcLineOfBusinessRestServiceImpl">
<property name="upcLineOfBusinessDao">
<ref bean="upcLineOfBusinessDao" />
</property>
<property name="upcUserDao">
<ref bean="upcUserDao" />
</property>
</bean>
</beans>
次は
@Path("/")
public classUpcLineOfBusinessRestService {
@POST
@ConsumeMime("application/xml")
@ProduceMime("application/xml")
@Path("/create")
public UpcLineOfBusinessEntity createUpcLineOfBusinessEntity(
UpcLineOfBusinessEntity upcLineOfBusinessEntity)
throws GenericUpcException
私のリソースクラスであり、私はまた私のweb.xmlファイルにCXFサーブレットを宣言しました。
<servlet>
<servlet-name>CXFServlet</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
この4行は、私にはOKを見てくれ
ありがとうございました。私が@ProduceMimeを使用している理由は、Jboss6がcxf2.3.1にバンドルされているからです。このバージョンでは、jsr311-api-0.8-1.3.0.jarのみを使用できます。このjarファイルは、MIMEタイプの古いクラスのみを持ちます。どのようにデータをapplication/xmlとして投稿するのですか?そのHTMLページのコンテンツタイプをapplication/xmlとして設定する必要がありますか?ここで私はデータを投稿するためにプレーンHTMLフォームを使用しています。 – Dilip
当面は、Consumes注釈値をapplication/x-www-form-urlencodedに変更しました。その後、私はHTMLフォームのPOSTメソッドを使用してリソースを呼び出そうとしていますが、新しい例外が発生しています。要求クラスのメッセージボディリーダーが見つかりません:UpcLineOfBusinessEntity、ContentType:application/x-www-form-urlencoded。 Googleに基づいて、CXFでJAXBを設定する必要があることを理解しています。そこで、次の行をcxf.xmlに追加しました...... – Dilip