在使用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個參數了,才報了上面的錯誤。