在使用spring ws 开发webservice 时,遇到如下错误:
No adapter for endpoint [public com.ibm.eve.schemas.RequestChargeResponse com.ibm.eve.ws.RequestChargeEndpoint.requestCharge(long)]: Is your endpoint annotated with @Endpoint, or does it implement a supported interface like MessageHandler or PayloadEndpoint?
网上搜到一个解决方案:http://stackoverflow.com/questions/4975721/jaxb-spring-ws-no-adapter-for-endpoint-while-using-jaxbelement
但是试了一下,不是这个问题。
我写的xsd没有问题,
找了半天,原来请求接口写错了,如果你的请求的方法中参数是一个对象:
<xs:element name="RequestChargeRequest">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="Vin" type="xs:string"/>
<xs:element minOccurs="0" name="Soc" type="xs:double"/>
<xs:element minOccurs="0" name="ConnVoltage" type="xs:int"/>
<xs:element name="TimeRange" type="eve:TimeRange"/>
<xs:element name="GeoLocation" type="eve:GeoLocation"/>
</xs:sequence>
</xs:complexType>
</xs:element>
那在你的Endpoint对应的方法上一定也要是这个对象:
@PayloadRoot(localPart = "RequestChargeRequest", namespace = "http://ibm.com/eve/schemas")
@Namespace(prefix = "sch", uri="http://ibm.com/eve/schemas")
public RequestChargeResponse requestCharge(RequestChargeRequest request) {
我开始写成里面的5个参数了,才报了上面的错误。
在使用Spring WS开发Web服务时遇到'No adapter for endpoint'错误。错误提示可能误导为JAXB配置问题,但实际原因是请求接口的方法参数定义不匹配。当XML元素是复杂类型时,Endpoint的方法必须接受该复杂类型的对象作为参数,而非单独的字段。修正接口定义后,问题得到解决。
4747

被折叠的 条评论
为什么被折叠?



