<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 2,  comments - 2,  trackbacks - 0
      2006年9月21日

    1、Aegis Binding這是XFire默認的綁定方式。
    ????? 他的特點是支持簡單的綁定,不支持復雜的shema綁定。如果要實現復雜的schema綁定,需要自定義實現Type。
    ?????? 1)public PurchaseOrderType receiveOrder(PurchaseOrderType po){......}
    ?????? 2)public class PurchaseOrderType extends Type
    ??????????? {
    ????
    ?????????????????public ReferenceToDataType() {
    ??????????????????????setTypeClass(PurchaseOrderType.class);
    ??????????????????????setSchemaType(new QName(.. the QName of the type you're returning ..));
    ?????????????????}

    ?????????????????public void writeObject(Object value, XMLStreamWriter writer,?
    ????????????????????????????????????MessageContext context)
    ?????????????????{
    ??????????????????????PurchaseOrderType data = (PurchaseOrderType) value;
    ??????????????????????... do you're writing to the writer
    ?????????????????}

    ?????????????????publicObject readObject( MessageReader reader, MessageContext context )
    ?????????????????{
    ??????????????????????// If you're reading you can read in a reference to the data
    ??????????????????????XMLStreamReader reader = context.getInMessage().getXMLStreamReader();

    ??????????????????????PurchaseOrderType data = read(reader);
    ??????????????????????return data;
    ?????????????????}

    ?????????????????public void writeSchema(Element schemaRoot)
    ?????????????????{
    ??????????????????????// override this to write out your schema
    ??????????????????????// if you have it in DOM form you can convert it to YOM via DOMConverter
    ?????????????????}
    ???????????????}
    2、Jibx綁定
    ???? 這種類型的綁定相對來說不需要自己寫額外的代碼,代是需要自己在開發之前進行Jibx的預編譯,他會為我們生成相應的輔助類。但是這些東需要額外的配置,所以在開發過程中也不是很方便。
    3、XMLBeans綁定
    ??? 這種綁定支持任意復雜的schema,可以自動生成javabean代碼。
    ??
    ?? 唉,沒時間了,有空再繼續吧。現在先做個開始。

    posted @ 2006-09-21 13:26 吃飯不洗手 閱讀(1688) | 評論 (1)編輯 收藏

    1、使用org.codehaus.xfire.spring.XFireSpringServlet與ServiceBean

    1.1 web.xml的配置

    ?<web-app>
    ?<display-name>Spring Image Database</display-name>
    ?<description>Spring Image Database sample application</description>
    ?<!--
    ??These values are used by ContextLoaderListener, defined immediately below.
    ??????? The files listed below are used to initialize the business logic portion of the application.
    ??????? Each dispatcher servlet (defined further down) has their own configuration file,
    ??????? which may or may not depend on items in these files.
    ??? -->
    ??? <context-param>
    ?????? <param-name>contextConfigLocation</param-name>
    ?????? <param-value>
    ???? classpath:applicationContext-webservice.xml
    ??? </param-value>
    ??? </context-param>
    ?<!-- Log4j configuration listener-->
    ?<listener>
    ??<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
    ?</listener>
    ?<!-- Spring framework -->
    ?<listener>
    ??????? <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    ?</listener>

    ?<servlet>
    ??????? <servlet-name>XFireServlet</servlet-name>
    ??????? <display-name>XFire Servlet</display-name>
    ??????? <servlet-class>org.codehaus.xfire.spring.XFireSpringServlet</servlet-class>
    ??? </servlet>
    ??????????????
    ??? <servlet-mapping>
    ??????? <servlet-name>XFireServlet</servlet-name>
    ??????? <url-pattern>/services/*</url-pattern>
    ??? </servlet-mapping>

    ?<welcome-file-list>
    ??<welcome-file>index.jsp</welcome-file>
    ?</welcome-file-list>
    ?
    </web-app>

    1.2 applicationContext-webservice.xml的配置:

    <beans>

    ??? <import resource="classpath:org/codehaus/xfire/spring/xfire.xml"/>
    ???
    ??? <bean name="echoService" class="org.codehaus.xfire.spring.ServiceBean">
    ??????? <property name="serviceBean" ref="echo"/>
    ??????? <property name="serviceClass" value="org.codehaus.xfire.test.Echo"/>
    ??????? <property name="inHandlers">
    ??????????? <list>
    ??????????????? <ref bean="addressingHandler"/>
    ??????????? </list>
    ??????? </property>
    ??? </bean>

    ??? <bean id="echo" class="org.codehaus.xfire.test.EchoImpl"/>

    ??? <bean id="addressingHandler" class="org.codehaus.xfire.addressing.AddressingInHandler"/>
    ?
    ? ?<bean name="bookService" class="org.codehaus.xfire.spring.ServiceBean">
    ??????? <property name="serviceBean" ref="bookServiceBean"/>
    ??????? <property name="serviceClass" value="org.codehaus.xfire.demo.BookService"/>
    ??? </bean>

    ??? <bean id="bookServiceBean" class="org.codehaus.xfire.demo.BookServiceImpl"/>

    </beans>

    1.3 這樣將會發布兩個service,BookServiceEchoService。隨后就可以使用client端進行測試了。

    ???? //測試BookService
    ??? public static void main(String args[])
    ??? {?
    ??????? String serviceURL = "http://127.0.0.1:9001/xfire/services/BookService";
    ??????? Service serviceModel = new ObjectServiceFactory().create(BookService.class,null,"http://xfire.codehaus.org/BookService",null);
    ??????? XFireProxyFactory serviceFactory = new XFireProxyFactory();
    ??????? try
    ??????? {
    ??????????? BookService service = (BookService) serviceFactory.create(serviceModel, serviceURL);
    ??????????? Client client = Client.getInstance(service);
    ??????????? client.addOutHandler(new OutHeaderHandler());
    ??????????? Book[] books = service.getBooks();
    ??????????? System.out.println("BOOKS:");
    ??????????? for (int i = 0; i < books.length; i++)
    ??????????? {
    ??????????????? System.out.println(books[i].getTitle());
    ??????????? }
    ??????? }
    ??????? catch (MalformedURLException e)
    ??????? {
    ??????????? e.printStackTrace();
    ??????? }
    ??? }

    1.4 忘了BookService及其實現了。

    ???? public interface BookService
    ??? {
    ???????????? ?public Book[] getBooks();
    ???
    ????????????? public Book findBook(String isbn);
    ???
    ???????????? public Map getBooksMap();
    ?? }

    ?

    ??? public class BookServiceImpl implements BookService
    ??? {
    ??? private Book onlyBook;
    ???
    ??? public BookServiceImpl()
    ??? {
    ??????? onlyBook = new Book();
    ??????? onlyBook.setAuthor("Dan Diephouse");
    ??????? onlyBook.setTitle("Using XFire");
    ??????? onlyBook.setIsbn("0123456789");
    ???? }

    ???? public Book[] getBooks()
    ???? {
    ??????? return new Book[] { onlyBook };
    ???? }
    ???
    ???? public Book findBook(String isbn)
    ???? {
    ??????? if (isbn.equals(onlyBook.getIsbn()))
    ??????????? return onlyBook;
    ???????
    ??????? return null;
    ???? }

    ???? public Map getBooksMap() {
    ??Map result = new HashMap();
    ??result.put(onlyBook.getIsbn(), onlyBook);
    ??return result;
    ???? }
    ??? }

    1.5 簡單的測試就是通過IE,輸入http://ip:port/context/services/BookService?wsdl或者http://ip:port/context/services/EchoService?wsdl,將會出現相應的wsdl文檔。

    ???? 如果只是輸入http://ip:port/context/services/BookService,會出現Invalid SOAP request.這也說明配置正確。

    2、直接集成Spring(通過Spring的org.springframework.web.servlet.DispatcherServlet)

    2.1 web.xml配置
    <web-app>
    <!-- START SNIPPET: xfire -->
    ??? <context-param>
    ??????? <param-name>contextConfigLocation</param-name>
    ??????? <param-value>
    ??????? classpath:org/codehaus/xfire/spring/xfire.xml</param-value>
    ??? </context-param>

    ??? <context-param>
    ??????? <param-name>log4jConfigLocation</param-name>
    ??????? <param-value>/WEB-INF/log4j.properties</param-value>
    ??? </context-param>

    ??? <listener>
    ??????? <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
    ??? </listener>

    ??? <listener>
    ??????? <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    ??? </listener>

    ??? <servlet>
    ??????? <servlet-name>xfire</servlet-name>
    ??????? <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    ??? </servlet>

    ??? <servlet-mapping>
    ??????? <servlet-name>xfire</servlet-name>
    ??????? <url-pattern>/*</url-pattern>
    ??? </servlet-mapping>
    <!-- END SNIPPET: xfire -->
    </web-app>
    2.2 xfire-servlet.xml配置
    <beans>
    ??? <!-- START SNIPPET: xfire -->
    ??? <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    ??????? <property name="urlMap">
    ??????????? <map>
    ??????????????? <entry key="/EchoService">
    ??????????????????? <ref bean="echo"/>
    ??????????????? </entry>
    ??????????? </map>
    ??????? </property>
    ??? </bean>

    ??? <bean id="echoBean" class="org.codehaus.xfire.spring.example.EchoImpl"/>

    ??? <!-- Declare a parent bean with all properties common to both services -->
    ??? <bean id="echo" class="org.codehaus.xfire.spring.remoting.XFireExporter">
    ??????? <property name="serviceFactory">
    ??????????? <ref bean="xfire.serviceFactory"/>
    ??????? </property>
    ??????? <property name="xfire">
    ??????????? <ref bean="xfire"/>
    ??????? </property>
    ??????? <property name="serviceBean">
    ??????????? <ref bean="echoBean"/>
    ??????? </property>
    ??????? <property name="serviceClass">
    ??????????? <value>org.codehaus.xfire.spring.example.Echo</value>
    ??????? </property>
    ??? </bean>
    ??? <!-- END SNIPPET: xfire -->
    </beans>
    2.3 余下的配置跟第一種方法一樣。

    3、另外xfire的官方文檔上還有一種方法,是通過XBean與Spring結合來實現webservice的expose。還是覺得上面的兩種方法比較好。既然已經與spring集成在一起了,何必再引入其他的呢?以后的維護是不是也要有問題呢?

    ?在隨后的文章里將會介紹xfire與Jibx結合的例子。

    posted @ 2006-09-21 09:42 吃飯不洗手 閱讀(1931) | 評論 (1)編輯 收藏
    僅列出標題  
    主站蜘蛛池模板: 久久久久久夜精品精品免费啦| ww在线观视频免费观看| 午夜成人免费视频| 亚洲AV无码国产精品色| 99爱在线精品免费观看| ass亚洲**毛茸茸pics| 国产片AV片永久免费观看| 午夜亚洲国产成人不卡在线| 国产日产亚洲系列| 三年片免费高清版 | 国产92成人精品视频免费| 亚洲一区二区三区首页| 中文字幕在线免费| 亚洲一区二区三区免费观看| 无码日韩精品一区二区免费| 亚洲精品伦理熟女国产一区二区 | 亚洲伦乱亚洲h视频| 亚洲天堂免费在线视频| 久久精品国产精品亚洲艾| 免费在线观看h片| 亚洲一本一道一区二区三区| 国产网站免费观看| 亚洲jjzzjjzz在线播放| 日韩免费观看的一级毛片| 午夜肉伦伦影院久久精品免费看国产一区二区三区| 91大神在线免费观看| 亚洲人成77777在线播放网站不卡| 好吊妞在线成人免费| 高潮毛片无遮挡高清免费视频| 好大好深好猛好爽视频免费| 特级一级毛片免费看| 亚洲福利视频导航| 性生交片免费无码看人| 菠萝菠萝蜜在线免费视频| 亚洲a一级免费视频| 天堂在线免费观看中文版| 美女网站在线观看视频免费的| 亚洲国产精品成人| 日韩免费无码一区二区三区 | 久久亚洲精品中文字幕三区| 男女做羞羞的事视频免费观看无遮挡|