在使用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个参数了,才报了上面的错误。