如何生成一个java web服务类到WSDL文件,该文件与sudzc.com一起使用来创建Objective-C代码?

时间:2012-08-06 15:32:09

标签: objective-c web-services soap wsdl sudzc

如何从Java Web Service类生成一个WSDL文件,Sudzc.com支持该文件生成Objective-C代码?

我试着用一个简单的例子。

我的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);
    }

}

我使用ant-script和wsgen创建一个WSDL文件,然后我将其上传到http://sudzc.com以创建Objective-C代码(带有ARC的iOS的Objective-C)。我的问题是,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生成Objective-C代码时,它工作正常,我可以使用实例方法 我的Objective-C项目中的Web服务... !!!

也许有人可以提供帮助?

P.S。抱歉我的英语不好,我是网络服务的绝对初学者......

2 个答案:

答案 0 :(得分:0)

sudzC在内存方面存在很多问题,我使用WSClient ++生成类,从来没有遇到过问题。

http://wsclient.neurospeech.com/

答案 1 :(得分:-1)

问题是生成的RectangleWebService.wsdl文件是从外部schema1.xsd文件导入模式...

所以我必须创建一个wsdl文件然后它应该与sudzc.com一起使用...

我猜对了吗?