输入参数是Object需不需要用XmlJavaTypeAdapter转换一下吗?

3 views
Skip to first unread message

Jackey Ding

unread,
May 9, 2008, 3:11:31 AM5/9/08
to cxf...@googlegroups.com
Hi,
 
我现在写的一个Service,输入输出参数都是Object,已经成功发布,能够看到WDSL。但是客户端调用一直没有调通,出错信息如下。是不是需不需要用XmlJavaTypeAdapter转换一下?
 
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Error reading XMLStreamReader.
 at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:218)
 at $Proxy21.findService(Unknown Source)
 at symphony.serviceengines.servicedirector.ClientTest.main(ClientTest.java:44)
Caused by: org.apache.cxf.binding.soap.SoapFault: Error reading XMLStreamReader.
 at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:70)
 at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:35)
 at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:221)
 at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:96)
 at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:65)
 at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:34)
 at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:221)
 at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:429)
 at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1988)
 at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1824)
 at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
 at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:583)
 at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
 at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:221)
 at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:276)
 at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:222)
 at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
 at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:177)
 ... 2 more
Jackey

Freeman Fang

unread,
May 9, 2008, 3:20:41 AM5/9/08
to cxf...@googlegroups.com
我猜你是用code first的方式,对吧
能不能把你的SEI给发过来看看,还有生成的wsdl是什么样自得最好也发过来

我觉得不是特别需要最好不用XmlJavaTypeAdapter,定制jaxb的映射关系主要是为
了和以前的遗留接口兼容(给人认为是error-prone),你有这样的需求么?
如果是重新开发的接口,通过正确的annotation都应该能搞定


Jackey Ding wrote:
> Hi,
> 我现在写的一个Service,输入输出参数都是Object,已经成功发布,能够看到
> WDSL。但是客户端调用一直没有调通,出错信息如下。是不是需不需要用

Jackey Ding

unread,
May 9, 2008, 3:25:14 AM5/9/08
to cxf...@googlegroups.com
:D被你才对了,Code first,还不怎么精通WSDL的写法,只好先写Java类了。
 

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="IMediatorService" targetNamespace="http://mediator.agent.integration.symphony/" xmlns:tns="http://mediator.agent.integration.symphony/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://mediator.agent.integration.symphony/" attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://mediator.agent.integration.symphony/">
    <xs:element name="findService" type="tns:findService"/>
    <xs:element name="findServiceResponse" type="tns:findServiceResponse"/>
    <xs:complexType name="findService">
        <xs:sequence>
            <xs:element minOccurs="0" name="arg0" type="tns:siContext"/>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="siContext">
        <xs:sequence>
            <xs:element minOccurs="0" name="name" type="xs:string"/>
            <xs:element minOccurs="0" name="version" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="findServiceResponse">
        <xs:sequence>
            <xs:element minOccurs="0" name="return" type="tns:serviceInfo"/>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="serviceInfo">
        <xs:sequence>
            <xs:element minOccurs="0" name="serviceName" type="xs:string"/>
            <xs:element minOccurs="0" name="serviceVersion" type="xs:string"/>
            <xs:element minOccurs="0" name="soap" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>
    <xs:element name="SymphonyIntegrationException" type="tns:SymphonyIntegrationException"/>
    <xs:complexType name="SymphonyIntegrationException">
        <xs:sequence/>
    </xs:complexType>
</xs:schema>
  </wsdl:types>
  <wsdl:message name="findServiceResponse">
    <wsdl:part name="parameters" element="tns:findServiceResponse">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="findService">
    <wsdl:part name="parameters" element="tns:findService">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="SymphonyIntegrationException">
    <wsdl:part name="SymphonyIntegrationException" element="tns:SymphonyIntegrationException">
    </wsdl:part>
  </wsdl:message>
  <wsdl:portType name="IMediator">
    <wsdl:operation name="findService">
      <wsdl:input name="findService" message="tns:findService">
    </wsdl:input>
      <wsdl:output name="findServiceResponse" message="tns:findServiceResponse">
    </wsdl:output>
      <wsdl:fault name="SymphonyIntegrationException" message="tns:SymphonyIntegrationException">
    </wsdl:fault>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="IMediatorServiceSoapBinding" type="tns:IMediator">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="findService">
      <soap:operation soapAction="" style="document"/>
      <wsdl:input name="findService">
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output name="findServiceResponse">
        <soap:body use="literal"/>
      </wsdl:output>
      <wsdl:fault name="SymphonyIntegrationException">
        <soap:fault name="SymphonyIntegrationException" use="literal"/>
      </wsdl:fault>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="IMediatorService">
    <wsdl:port name="IMediatorPort" binding="tns:IMediatorServiceSoapBinding">
      <soap:address location="http://localhost:9090/IMediatorPort"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>
还有,如果没有写annotation,直接生成的WSDL用的是jaxb Binding吗?
 
Jackey
2008/5/9 Freeman Fang <freema...@gmail.com>:

Freeman Fang

unread,
May 9, 2008, 3:32:05 AM5/9/08
to cxf...@googlegroups.com
对,缺省的是用jaxb,你可以在java2wsdl里面指定你想用的databinding

你最好把SEI(service endpoint info),就是你写的java 接口一起发上来

> <http://schemas.xmlsoap.org/soap/http%22/>>


> <wsdl:operation name="findService">
> <soap:operation soapAction="" style="document"/>
> <wsdl:input name="findService">
> <soap:body use="literal"/>
> </wsdl:input>
> <wsdl:output name="findServiceResponse">
> <soap:body use="literal"/>
> </wsdl:output>
> <wsdl:fault name="SymphonyIntegrationException">
> <soap:fault name="SymphonyIntegrationException" use="literal"/>
> </wsdl:fault>
> </wsdl:operation>
> </wsdl:binding>
> <wsdl:service name="IMediatorService">
> <wsdl:port name="IMediatorPort" binding="tns:IMediatorServiceSoapBinding">
> <soap:address location="http://localhost:9090/IMediatorPort"/

> <http://localhost:9090/IMediatorPort%22/>>


> </wsdl:port>
> </wsdl:service>
> </wsdl:definitions>
> 还有,如果没有写annotation,直接生成的WSDL用的是jaxb Binding吗?
> Jackey
> 2008/5/9 Freeman Fang <freema...@gmail.com

> <mailto:freema...@gmail.com>>:

Jackey Ding

unread,
May 9, 2008, 3:35:32 AM5/9/08
to cxf...@googlegroups.com
====================================================================
@WebService
public interface IMediator {
 @WebMethod
 public ServiceInfo findService(SIContext context) throws SymphonyIntegrationException;
}
 
====================================================================
SIContext
public class SIContext {
 private String appVersion;
 private String appName;
 
 public SIContext(){
  
 }
 public String getVersion() {
  return appVersion;
 }
 public void setVersion(String appVersion) {
  this.appVersion = appVersion;
 }
 public String getName() {
  return appName;
 }
 public void setName(String appName) {
  this.appName = appName;
 }
}
 
====================================================================
ServiceInfo
public class ServiceInfo {
 private String serviceName;
 private String soap;
 private String serviceVersion;
 public ServiceInfo() {
 }
 
 
 
 public String getServiceName() {
  return serviceName;
 }
 

 public void setServiceName(String serviceName) {
  this.serviceName = serviceName;
 }
 

 public String getSoap() {
  return soap;
 }
 

 public void setSoap(String soap) {
  this.soap = soap;
 }
 

 public String getServiceVersion() {
  return serviceVersion;
 }
 

 public void setServiceVersion(String serviceVersion) {
  this.serviceVersion = serviceVersion;
 }
}
====================================================================
 
Jackey
2008/5/9 Freeman Fang <freema...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages