Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > Delphi: Общие вопросы > Delphi7 + WebService(Java)


Автор: le0ne 3.3.2011, 12:03
Есть простейший тестовый веб-сервис написанный на Java. Пробую написать клиент на D7 для работы с сервисом, но возникает проблема при WSDL-импорте: создается пустой unit с текстом
Код

   ...
  // ************************************************************************ //
  // 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.
  // ************************************************************************ //
   ...


Java-код сервиса:

Код


package pkg;

public class MyService {
    public Boolean Configure(String param, String val)
        {    return true;    }
    public Boolean StartMe()
       {    return true;    }
    public Boolean StopMe()
       {   return true;    }
    public String getStatus()
       {   return "No status available!";    }
}


Веб-сервис опубликован на Apache Tomcat/7.0.8 + Axis2-1.5.4

Может кто знает как решить данную проблему с WSDL-импортом?

WSDL:

Код

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://pkg" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://pkg">
    <wsdl:documentation>
        Please Type your service description here
    </wsdl:documentation>
    <wsdl:types>
        <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://pkg">
            <xs:element name="getStatusResponse">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element name="StopMeResponse">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element minOccurs="0" name="return" type="xs:boolean"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element name="StartMeResponse">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element minOccurs="0" name="return" type="xs:boolean"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element name="Configure">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element minOccurs="0" name="param" nillable="true" type="xs:string"/>
                        <xs:element minOccurs="0" name="val" nillable="true" type="xs:string"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element name="ConfigureResponse">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element minOccurs="0" name="return" type="xs:boolean"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:schema>
    </wsdl:types>
    <wsdl:message name="StartMeRequest"/>
    <wsdl:message name="StartMeResponse">
        <wsdl:part name="parameters" element="ns:StartMeResponse"/>
    </wsdl:message>
    <wsdl:message name="ConfigureRequest">
        <wsdl:part name="parameters" element="ns:Configure"/>
    </wsdl:message>
    <wsdl:message name="ConfigureResponse">
        <wsdl:part name="parameters" element="ns:ConfigureResponse"/>
    </wsdl:message>
    <wsdl:message name="getStatusRequest"/>
    <wsdl:message name="getStatusResponse">
        <wsdl:part name="parameters" element="ns:getStatusResponse"/>
    </wsdl:message>
    <wsdl:message name="StopMeRequest"/>
    <wsdl:message name="StopMeResponse">
        <wsdl:part name="parameters" element="ns:StopMeResponse"/>
    </wsdl:message>
    <wsdl:portType name="MyServicePortType">
        <wsdl:operation name="StartMe">
            <wsdl:input message="ns:StartMeRequest" wsaw:Action="urn:StartMe"/>
            <wsdl:output message="ns:StartMeResponse" wsaw:Action="urn:StartMeResponse"/>
        </wsdl:operation>
        <wsdl:operation name="Configure">
            <wsdl:input message="ns:ConfigureRequest" wsaw:Action="urn:Configure"/>
            <wsdl:output message="ns:ConfigureResponse" wsaw:Action="urn:ConfigureResponse"/>
        </wsdl:operation>
        <wsdl:operation name="getStatus">
            <wsdl:input message="ns:getStatusRequest" wsaw:Action="urn:getStatus"/>
            <wsdl:output message="ns:getStatusResponse" wsaw:Action="urn:getStatusResponse"/>
        </wsdl:operation>
        <wsdl:operation name="StopMe">
            <wsdl:input message="ns:StopMeRequest" wsaw:Action="urn:StopMe"/>
            <wsdl:output message="ns:StopMeResponse" wsaw:Action="urn:StopMeResponse"/>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="MyServiceSoap11Binding" type="ns:MyServicePortType">
        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
        <wsdl:operation name="StartMe">
            <soap:operation soapAction="urn:StartMe" style="document"/>
            <wsdl:input>
                <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="Configure">
            <soap:operation soapAction="urn:Configure" style="document"/>
            <wsdl:input>
                <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="getStatus">
            <soap:operation soapAction="urn:getStatus" style="document"/>
            <wsdl:input>
                <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="StopMe">
            <soap:operation soapAction="urn:StopMe" style="document"/>
            <wsdl:input>
                <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:binding name="MyServiceSoap12Binding" type="ns:MyServicePortType">
        <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
        <wsdl:operation name="StartMe">
            <soap12:operation soapAction="urn:StartMe" style="document"/>
            <wsdl:input>
                <soap12:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap12:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="Configure">
            <soap12:operation soapAction="urn:Configure" style="document"/>
            <wsdl:input>
                <soap12:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap12:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="getStatus">
            <soap12:operation soapAction="urn:getStatus" style="document"/>
            <wsdl:input>
                <soap12:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap12:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="StopMe">
            <soap12:operation soapAction="urn:StopMe" style="document"/>
            <wsdl:input>
                <soap12:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap12:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:binding name="MyServiceHttpBinding" type="ns:MyServicePortType">
        <http:binding verb="POST"/>
        <wsdl:operation name="StartMe">
            <http:operation location="MyService/StartMe"/>
            <wsdl:input>
                <mime:content type="text/xml" part="StartMe"/>
            </wsdl:input>
            <wsdl:output>
                <mime:content type="text/xml" part="StartMe"/>
            </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="Configure">
            <http:operation location="MyService/Configure"/>
            <wsdl:input>
                <mime:content type="text/xml" part="Configure"/>
            </wsdl:input>
            <wsdl:output>
                <mime:content type="text/xml" part="Configure"/>
            </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="getStatus">
            <http:operation location="MyService/getStatus"/>
            <wsdl:input>
                <mime:content type="text/xml" part="getStatus"/>
            </wsdl:input>
            <wsdl:output>
                <mime:content type="text/xml" part="getStatus"/>
            </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="StopMe">
            <http:operation location="MyService/StopMe"/>
            <wsdl:input>
                <mime:content type="text/xml" part="StopMe"/>
            </wsdl:input>
            <wsdl:output>
                <mime:content type="text/xml" part="StopMe"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="MyService">
        <wsdl:port name="MyServiceHttpSoap11Endpoint" binding="ns:MyServiceSoap11Binding">
            <soap:address location="http://localhost:8080/ResourceA/services/MyService.MyServiceHttpSoap11Endpoint/"/>
        </wsdl:port>
        <wsdl:port name="MyServiceHttpSoap12Endpoint" binding="ns:MyServiceSoap12Binding">
            <soap12:address location="http://localhost:8080/ResourceA/services/MyService.MyServiceHttpSoap12Endpoint/"/>
        </wsdl:port>
        <wsdl:port name="MyServiceHttpEndpoint" binding="ns:MyServiceHttpBinding">
            <http:address location="http://localhost:8080/ResourceA/services/MyService.MyServiceHttpEndpoint/"/>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>
 

Автор: cat512 3.3.2011, 17:00
Т.е. ты озабочен тем, что среда не сгенерила каркас класса/методов?

Автор: le0ne 4.3.2011, 15:41
Цитата(cat512 @ 3.3.2011,  17:00)
Т.е. ты озабочен тем, что среда не сгенерила каркас класса/методов?

Именно, хотелось бы узнать как можно решить проблему с авто-генерацией кода.
Либо если решения этой проблемы нету, то узнать линк на хорошую теорию по реализации клиента для ВебСервисов на Delphi без использования утилиты WSDLimp

Автор: cat512 5.3.2011, 15:45
Цитата(le0ne @ 4.3.2011,  15:41)
Цитата(cat512 @ 3.3.2011,  17:00)
Т.е. ты озабочен тем, что среда не сгенерила каркас класса/методов?

Именно, хотелось бы узнать как можно решить проблему с авто-генерацией кода.
Либо если решения этой проблемы нету, то узнать линк на хорошую теорию по реализации клиента для ВебСервисов на Delphi без использования утилиты WSDLimp

Какая версия дельфы?
Скорее всего что, штатно  импортёр работает с версией soap 1.1, а у тебя soap 1.2. Вроде у 2010 дэльфы импортёр умеет работать с 1.2. В любом случае на имбаркадеро есть импортёр последней версии.
http://cc.embarcadero.com/Item/24535

Добавлено @ 15:49
http://www.delphisources.ru/pages/faq/base/web_services.html

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)