如何從Java Web Service類生成WSDL文件,Sudzc.com支持生成Objective-C代碼?如何將java web服務類生成爲與sudzc.com一起使用以創建Objective-C代碼的WSDL文件?
我試了一個簡單的例子。 我的Java Web服務類:
package main;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
@WebService(name="RectangleWebService", serviceName = "RectangleWebService", portName = "RectangleWebServicePort", targetNamespace = "http://www.mywstest.com/ws/rectangle")
public class RectangleService {
@WebMethod(action="calculateValueOne")
public @WebResult(name="ValueOne") float calculateValueOne(@WebParam(name="Length") float length, @WebParam(name="Width")float width){
return 2*(length+width);
}
@WebMethod(action="calculateValueTwo")
public @WebResult(name="ValueTwo") float calculateValueTwo(@WebParam(name="Length") float length, @WebParam(name="Width")float width){
return (length*width);
}
}
我創建了一個WSDL文件與螞蟻腳本和WSGEN,然後我上傳它http://sudzc.com創建Objectiv-C代碼(Objectiv-C適用於iOS與ARC) 。我的問題是,從Sudzc.com創建的Objective-C代碼沒有實例方法...
這是我的WSDL文件:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6. -->
<definitions targetNamespace="http://www.mywstest.com" name="RectangleWebService" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://www.mywstest.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<import namespace="http://www.mywstest.com/ws/rectangle" location="RectangleWebServicePortType.wsdl"/>
<binding name="RectangleWebServicePortBinding" type="ns1:RectangleWebService" xmlns:ns1="http://www.mywstest.com/ws/rectangle">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="calculateValueOne">
<soap:operation soapAction="calculateValueOne"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="calculateValueTwo">
<soap:operation soapAction="calculateValueTwo"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="RectangleWebService">
<port name="RectangleWebServicePort" binding="tns:RectangleWebServicePortBinding">
<soap:address location="REPLACE_WITH_ACTUAL_URL"/>
</port>
</service>
</definitions>
當我使用從http://www.w3schools.com/webservices/tempconvert.asmx?WSDL的WSDL文件生成與sudzc.com的Objectiv-C代碼,它工作正常,我可以在我的Objective-C項目中使用web服務的實例方法 ...... !!!
也許有人可以幫忙嗎?
P.S.對不起,我的英文不好,我在Web服務的絕對初學者...