用java 写了个简单的web service 包括一个weather 类,和 getweather ,setweather 两个方法。生成的wsdl文件如下- <wsdl:definitions xmlns:axis2="http://service.pojo.sample" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:ns0="http://data.pojo.sample/xsd" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ns1="http://service.pojo.sample/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://service.pojo.sample">
  <wsdl:documentation>Weather POJO Service</wsdl:documentation> 
- <wsdl:types>
- <xs:schema xmlns:ax21="http://data.pojo.sample/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://data.pojo.sample/xsd">
  <xs:element name="Weather" type="ax21:Weather" /> 
- <xs:complexType name="Weather">
- <xs:sequence>
  <xs:element name="forecast" nillable="true" type="xs:string" /> 
  <xs:element name="howMuchRain" type="xs:float" /> 
  <xs:element name="rain" type="xs:boolean" /> 
  <xs:element name="temperature" type="xs:float" /> 
  </xs:sequence>
  </xs:complexType>
  </xs:schema>
- <xs:schema xmlns:ns="http://service.pojo.sample/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://service.pojo.sample/xsd">
- <xs:element name="getWeatherResponse">
- <xs:complexType>
- <xs:sequence>
  <xs:element name="return" nillable="true" type="ns0:Weather" /> 
  </xs:sequence>
  </xs:complexType>
  </xs:element>
- <xs:element name="setWeather">
- <xs:complexType>
- <xs:sequence>
  <xs:element name="weather" nillable="true" type="ns0:Weather" /> 
  </xs:sequence>
  </xs:complexType>
  </xs:element>
  </xs:schema>
  </wsdl:types>
  <wsdl:message name="getWeatherMessage" /> 
- <wsdl:message name="getWeatherResponse">
  <wsdl:part name="part1" element="ns1:getWeatherResponse" /> 
  </wsdl:message>
- <wsdl:message name="setWeatherMessage">
  <wsdl:part name="part1" element="ns1:setWeather" /> 
  </wsdl:message>
- <wsdl:portType name="WeatherServicePortType">
- <wsdl:operation name="getWeather">
  <wsdl:input xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" message="axis2:getWeatherMessage" wsaw:Action="urn:getWeather" /> 
  <wsdl:output message="axis2:getWeatherResponse" /> 
  </wsdl:operation>
- <wsdl:operation name="setWeather">
  <wsdl:input xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" message="axis2:setWeatherMessage" wsaw:Action="urn:setWeather" /> 
  </wsdl:operation>
  </wsdl:portType>
- <wsdl:binding name="WeatherServiceSOAP11Binding" type="axis2:WeatherServicePortType">
  <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> 
- <wsdl:operation name="getWeather">
  <soap:operation soapAction="urn:getWeather" style="document" /> 
- <wsdl:input>
  <soap:body use="literal" /> 
  </wsdl:input>
- <wsdl:output>
  <soap:body use="literal" /> 
  </wsdl:output>
  </wsdl:operation>
- <wsdl:operation name="setWeather">
  <soap:operation soapAction="urn:setWeather" style="document" /> 
- <wsdl:input>
  <soap:body use="literal" /> 
  </wsdl:input>
  </wsdl:operation>
  </wsdl:binding>
- <wsdl:binding name="WeatherServiceSOAP12Binding" type="axis2:WeatherServicePortType">
  <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> 
- <wsdl:operation name="getWeather">
  <soap12:operation soapAction="urn:getWeather" style="document" /> 
- <wsdl:input>
  <soap12:body use="literal" /> 
  </wsdl:input>
- <wsdl:output>
  <soap12:body use="literal" /> 
  </wsdl:output>
  </wsdl:operation>
- <wsdl:operation name="setWeather">
  <soap12:operation soapAction="urn:setWeather" style="document" /> 
- <wsdl:input>
  <soap12:body use="literal" /> 
  </wsdl:input>
  </wsdl:operation>
  </wsdl:binding>
- <wsdl:binding name="WeatherServiceHttpBinding" type="axis2:WeatherServicePortType">
  <http:binding verb="POST" /> 
- <wsdl:operation name="getWeather">
  <http:operation location="getWeather" /> 
- <wsdl:input>
  <mime:content type="text/xml" /> 
  </wsdl:input>
- <wsdl:output>
  <mime:content type="text/xml" /> 
  </wsdl:output>
  </wsdl:operation>
- <wsdl:operation name="setWeather">
  <http:operation location="setWeather" /> 
- <wsdl:input>
  <mime:content type="text/xml" /> 
  </wsdl:input>
  </wsdl:operation>
  </wsdl:binding>
- <wsdl:service name="WeatherService">
- <wsdl:port name="WeatherServiceSOAP11port_http" binding="axis2:WeatherServiceSOAP11Binding">
  <soap:address location="http://61.144.225.35:80/axis2/services/WeatherService" /> 
  </wsdl:port>
- <wsdl:port name="WeatherServiceSOAP12port_http" binding="axis2:WeatherServiceSOAP12Binding">
  <soap12:address location="http://61.144.225.35:80/axis2/services/WeatherService" /> 
  </wsdl:port>
- <wsdl:port name="WeatherServiceHttpport1" binding="axis2:WeatherServiceHttpBinding">
  <http:address location="http://61.144.225.35:80/axis2/rest/WeatherService" /> 
  </wsdl:port>
  </wsdl:service>
  </wsdl:definitions>
-------------------------------------------------------------------------------------------------------------------------------
我看过网上的一些delphi调用web service 的例子,在那些例子里,根据wsdl自动生成的接口里面都会有一个 ××××soap类,然后通过调用那些类来调用web service的方法。 
可是我在 delphi 2007里面根据这个wsdl生成的接口里面没有那个类, 用delphi 7.0 生成的接口里面什么都没有。 我估计delphi7 生成不了接口应该是wsdl的版本问题。 axis2 生成的wsdl应该是2.0版本的。 我的问题是   delphi 2007生成的接口应该如何调用呢? 哪位朋友做过类似的项目?指点一下?

解决方案 »

  1.   

    你使用delphi7没有导入成功吗?我没有d2007环境
      

  2.   

    delphi 7导入不了,产生的是一个空的接口单元。
      

  3.   

    恩,我把你的wsdl粘贴下来试了一下的确是一个空文件
    // ************************************************************************ //
    // The types declared in this file were generated from data read from the
    // WSDL File described below:
    // WSDL     : C:\Documents and Settings\Administrator\桌面\a.wsdl
    // (2008-2-28 11:55:57 - 1.33.2.5)
    // ************************************************************************ //unit a;interfaceuses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;type  // ************************************************************************ //
      // The following types, referred to in the WSDL document are not being represented
      // in this file. They are either aliases[@] of other types represented or were referred
      // to but never[!] declared in the document. The types from the latter category
      // typically map to predefined/known XML or Borland types; however, they could also 
      // indicate incorrect WSDL documents that failed to declare or import a schema type.
      // ************************************************************************ //
    implementationinitializationend.
      

  4.   

    你的webservices你使用其它语言测试了没有?
      

  5.   

    你不妨先写一个简单的hello world进行测试,看看有没有问题
      

  6.   

    我用java 调过,是可以调的。 wsdl本身没问题。 这个web service也就是个简单的测试用的。只是返回值不是字符串而是自定义类型。
      

  7.   

    听说d7的wsdl有bug,不知道是不是因为这个问题导致的
      

  8.   

    可以用SOAP那一组中的控件来调用,我是用delphi7 2007中没用过.
    如果需要我给你传一个例子.
    是四层的. client+Soap+com+数据库. 用到WEB服务.
      

  9.   

    楼上的,我有例子,但是是delphi 7的,我需要d2007的例子,不过仍然非常感谢。
      

  10.   

    因为Delphi7发布的时候,AXIS2还没有出生,Delphi7不兼容AXIS2的WSDL文档。    在默认情况下,D7导入AXIS2的WSDL后,生成的pas文件中没有对应的Web Service接口方法。
        所以默认情况下无法使用D7编写的客户端调用AXIS2的Web Service服务。但是好像有人搞定了,我也非常想知道。
      

  11.   

    这么深的帖都被挖出来了,嘎嘎D7确实不认识axis2格式
    但我的D2007/2010是简化版,WSDL Importer被禁掉了,试都没法试