Xfire unexpected character '>' (Code 62) Expected '='

Source: Internet
Author: User
Below the dotted line is the method of someone else found on the network. I tried to use this method when faced with unexpected character '>' (Code 62) Expected '=', but it did not work. Later I found that, when this error occurs, restart (1) myeclipse or (2) tomcat or (3) computer to solve the problem. ---------------------------------------------------- Statement: the first time WebService is developed, the first time xfire is used, and the WebService is a beginner.
Objective: To share experiences and memos
Time: 2008-01-22
Error Description: an error is returned when WebService is called:

Java code
  1. Org. codehaus. xfire. fault. xfirefault: Unexpected character '>' (Code 62) Expected '='
org.codehaus.xfire.fault.XFireFault: Unexpected character '>' (code 62) expected '='

Solution: Add the following Java code to the Web. xml file of the WebService application:

  1. <Filter>
  2. <Filter-Name> compressingfilter </filter-Name>
  3. <Filter-class>
  4. Com. planetj. servlet. Filter. Compression. compressingfilter
  5. </Filter-class>
  6. <Init-param>
  7. <Param-Name> debug </param-Name>
  8. <Param-value> false </param-value>
  9. </Init-param>
  10. <Init-param>
  11. <Param-Name> statsenabled </param-Name>
  12. <Param-value> true </param-value>
  13. </Init-param>
  14. </Filter>
  15. <Filter-mapping>
  16. <Filter-Name> compressingfilter </filter-Name>
  17. <URL-pattern>/services/* </url-pattern>
  18. </Filter-mapping>
    <filter><filter-name>CompressingFilter</filter-name><filter-class>com.planetj.servlet.filter.compression.CompressingFilter</filter-class><init-param><param-name>debug</param-name><param-value>false</param-value></init-param><init-param><param-name>statsEnabled</param-name><param-value>true</param-value></init-param></filter><filter-mapping><filter-name>CompressingFilter</filter-name><url-pattern>/services/*</url-pattern></filter-mapping>

Detailed description:
Development Environment:
Server: tomcat5.0
JDK: jdk1.4.2
IDE: myeclicpse6.0.0 GA + eclipse3.3
Others: xfire1.2.6
Brief development description (the code is sayhello, which is not described here ):
1. Create a web service project through myeclipse
2. Use myeclipse to add WebService:
Service name: sayany
Service Interface: isayany
Service impl. Class: isayanyimpl
The generated web. XML is as follows: Java code

  1. <? XML version = "1.0" encoding = "UTF-8"?>
  2. <Web-app xmlns = "http://java.sun.com/xml/ns/j2ee" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" version = "2.4" xsi: schemalocation = "http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
  3. <Servlet>
  4. <Servlet-Name> xfireservlet </servlet-Name>
  5. <Servlet-class> org. codehaus. xfire. Transport. http. xfirepolicableservlet </servlet-class>
  6. <Load-on-startup> 0 </load-on-startup>
  7. </Servlet>
  8. <Servlet-mapping>
  9. <Servlet-Name> xfireservlet </servlet-Name>
  10. <URL-pattern>/services/* </url-pattern>
  11. </Servlet-mapping>
  12. <Welcome-file-List>
  13. <Welcome-File> index. jsp </welcome-File>
  14. </Welcome-file-List>
  15. </Web-app>
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">  <servlet>     <servlet-name>XFireServlet</servlet-name>    <servlet-class>org.codehaus.xfire.transport.http.XFireConfigurableServlet</servlet-class>    <load-on-startup>0</load-on-startup>  </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>

Services. XML content is as follows: (for beginners, in the same directory as webroot under the project, myeclipse automatically generates a WebServices directory, services. XML in this directory) Java code

  1. <Beans xmlns = "http://xfire.codehaus.org/config/1.0">
  2. <Service>
  3. <Name> sayany </Name>
  4. <Serviceclass> com. Jiang. Service. isayany </serviceclass>
  5. <Implementationclass> com. Jiang. Service. sayanyimpl </implementationclass>
  6. <Style> wrapped </style>
  7. <Use> literal </use>
  8. <Scope> application </scope>
  9. </Service>
  10. </Beans>
<beans xmlns="http://xfire.codehaus.org/config/1.0"><service><name>SayAny</name><serviceClass>com.jiang.service.ISayAny</serviceClass><implementationClass>com.jiang.service.SayAnyImpl</implementationClass><style>wrapped</style><use>literal</use><scope>application</scope></service></beans>

3. Directly publish to Tomcat through myeclipse;
4. Access http: // localhost/studywebservice/services/sayany? You can see an XML content in WSDL, which is not described here.
5. Compile the test program. The main method is as follows: Java code

  1. Public static void main (string [] ARGs ){
  2. String serviceurl = "http: // localhost/studywebservice/services/sayany ";
  3. String datas = "";
  4. // Service
  5. Service servicemodel = new objectservicefactory (). Create (
  6. Isayany. Class, null, "", null );
  7. Xfireproxyfactory servicefactory = new xfireproxyfactory ();
  8. Try {
  9. Isayany service = (isayany) servicefactory. Create (
  10. Servicemodel, serviceurl );
  11. Client client = (xfireproxy) proxy. getinvocationhandler (Service). getclient ();
  12. Client. setproperty (commonshttpmessagesender. gzip_enabled,
  13. Boolean. True );
  14. Client. setproperty (commonshttpmessagesender. http_timeout, "0 ");
  15. Datas = service. sayhello ("Jiang Shan ");
  16. System. Out. println (datas );
  17. } Catch (exception e ){
  18. E. printstacktrace ();
  19. }
  20. }
public static void main(String[] args) {String serviceURL = "http://localhost/studyWebService/services/SayAny";String datas = "";//serviceService serviceModel = new ObjectServiceFactory().create(ISayAny.class, null, "", null);XFireProxyFactory serviceFactory = new XFireProxyFactory();try {ISayAny service = (ISayAny) serviceFactory.create(serviceModel, serviceURL);Client client = ((XFireProxy) Proxy.getInvocationHandler(service)).getClient();client.setProperty(CommonsHttpMessageSender.GZIP_ENABLED,Boolean.TRUE);client.setProperty(CommonsHttpMessageSender.HTTP_TIMEOUT, "0");datas = service.sayHello("jiang shan");System.out.println(datas);} catch (Exception e) {e.printStackTrace();}}

Webserver obtains the corresponding information,

Java code
  1. Datas = service. sayhello ("Jiang Shan ");
datas = service.sayHello("jiang shan");

Error:
The error is as follows: Java code

  1. Com. Jiang. Service. testadstatdata-cocould not invoke service... nested exception is org. codehaus. xfire. fault. xfirefault: Unexpected character '>' (Code 62) Expected '='
  2. At [row, Col {unknown-source}]: [1,708]
  3. Org. codehaus. xfire. xfireruntimeexception: cocould not invoke service... nested exception is org. codehaus. xfire. fault. xfirefault: Unexpected character '>' (Code 62) Expected '='
  4. At [row, Col {unknown-source}]: [1,708]
  5. Org. codehaus. xfire. fault. xfirefault: Unexpected character '>' (Code 62) Expected '='
  6. At [row, Col {unknown-source}]: [1,708]
  7. At org. codehaus. xfire. fault. xfirefault. createfault (xfirefault. Java: 89)
  8. At org. codehaus. xfire. Client. Client. onreceive (client. Java: 391)
  9. At org. codehaus. xfire. Transport. http. httpchannel. sendviaclient (httpchannel. Java: 139)
  10. At org. codehaus. xfire. Transport. http. httpchannel. Send (httpchannel. Java: 48)
  11. At org. codehaus. xfire. handler. outmessagesender. Invoke (outmessagesender. Java: 26)
  12. At org. codehaus. xfire. handler. handlerpipeline. Invoke (handlerpipeline. Java: 131)
  13. At org. codehaus. xfire. Client. Invocation. Invoke (Invocation. Java: 75)
  14. At org. codehaus. xfire. Client. Client. Invoke (client. Java: 335)
  15. At org. codehaus. xfire. Client. xfireproxy. handlerequest (xfireproxy. Java: 77)
  16. At org. codehaus. xfire. Client. xfireproxy. Invoke (xfireproxy. Java: 57)
  17. At $ proxy0.getaddatabyuidandposid (unknown source)
  18. At com. Jiang. Service. testadstatdata. Main (testadstatdata. Java: 37)
  19. Caused by: COM. CTC. wstx. exc. wstxunexpectedcharexception: Unexpected character '>' (Code 62) Expected '='
  20. At [row, Col {unknown-source}]: [1,708]
  21. At com. CTC. wstx. sr. streamcompute. throwunexpectedchar (streamcompute. Java: 623)
  22. At com. CTC. wstx. sr. basicstreamreader. handlensattrs (basicstreamreader. Java: 2999)
  23. At com. CTC. wstx. sr. basicstreamreader. handlestartelem (basicstreamreader. Java: 2934)
  24. At com. CTC. wstx. sr. basicstreamreader. nextfromtree (basicstreamreader. Java: 2846)
  25. At com. CTC. wstx. sr. basicstreamreader. Next (basicstreamreader. Java: 1019)
  26. At org. codehaus. xfire. Soap. handler. readheadershandler. Invoke (readheadershandler. Java: 44)
  27. At org. codehaus. xfire. handler. handlerpipeline. Invoke (handlerpipeline. Java: 131)
  28. At org. codehaus. xfire. Client. Client. onreceive (client. Java: 387)
  29. ... 10 more
com.jiang.service.TestAdStatData  - Could not invoke service.. Nested exception is org.codehaus.xfire.fault.XFireFault: Unexpected character '>' (code 62) expected '=' at [row,col {unknown-source}]: [1,708]org.codehaus.xfire.XFireRuntimeException: Could not invoke service.. Nested exception is org.codehaus.xfire.fault.XFireFault: Unexpected character '>' (code 62) expected '=' at [row,col {unknown-source}]: [1,708]org.codehaus.xfire.fault.XFireFault: Unexpected character '>' (code 62) expected '=' at [row,col {unknown-source}]: [1,708]at org.codehaus.xfire.fault.XFireFault.createFault(XFireFault.java:89)at org.codehaus.xfire.client.Client.onReceive(Client.java:391)at org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.java:139)at org.codehaus.xfire.transport.http.HttpChannel.send(HttpChannel.java:48)at org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:26)at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:75)at org.codehaus.xfire.client.Client.invoke(Client.java:335)at org.codehaus.xfire.client.XFireProxy.handleRequest(XFireProxy.java:77)at org.codehaus.xfire.client.XFireProxy.invoke(XFireProxy.java:57)at $Proxy0.getAdDataByUidAndPosId(Unknown Source)at com.jiang.service.TestAdStatData.main(TestAdStatData.java:37)Caused by: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '>' (code 62) expected '=' at [row,col {unknown-source}]: [1,708]at com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:623)at com.ctc.wstx.sr.BasicStreamReader.handleNsAttrs(BasicStreamReader.java:2999)at com.ctc.wstx.sr.BasicStreamReader.handleStartElem(BasicStreamReader.java:2934)at com.ctc.wstx.sr.BasicStreamReader.nextFromTree(BasicStreamReader.java:2846)at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1019)at org.codehaus.xfire.soap.handler.ReadHeadersHandler.invoke(ReadHeadersHandler.java:44)at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)at org.codehaus.xfire.client.Client.onReceive(Client.java:387)... 10 more

Solution This article says: add the pjl-comp-filter-1.4.6.jar and configure the filter in Web. xml.

Cause of error: This sentence has a problem:

Java code
  1. Client. setproperty (commonshttpmessagesender. gzip_enabled, Boolean. True );
client.setProperty(CommonsHttpMessageSender.GZIP_ENABLED,Boolean.TRUE);

The gzip parameter is set during client calling, but the server does not use gzip to filter files!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.