You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Dmitry Trunikov <dm...@zoral.com.ua> on 2007/11/20 13:14:28 UTC

consume WSDL and call WS at runtime

Dear ALL!

There is trivial sample code which is not running in some reason. Please 
point me where is a bug.
Application should retrieve WSDL by URL and call method from that WS.
Code snippet:

import java.net.URL;
import javax.xml.namespace.QName;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.engine.AxisConfiguration;

public class Client {
    public static void main(String[] argv) {
        try {
            ServiceClient client = new ServiceClient(
                    null,
                    new 
URL("http://127.0.0.1:8080/axis2/services/MyService?wsdl"),
                    new QName("http://example1.userguide", "MyService"),
                    "MyServiceHttpport"
                    );
            OMFactory fac = OMAbstractFactory.getOMFactory();
            OMNamespace omNs = 
fac.createOMNamespace("http://example1.userguide", "ns1");
            OMElement method = fac.createOMElement("echo", omNs);
            OMElement value = fac.createOMElement("value", omNs);
            value.setText("Hello , my first service utilization");
            method.addChild(value);
            OMElement result = client.sendReceive(method);
            System.out.println(result);
        } catch (Throwable th) {
            th.printStackTrace();
        }
    }
}

Unfortunately it throws runtime error:

2007-11-20 13:43:02,632 ERROR 
org.apache.axis2.description.WSDL11ToAxisServiceBuilder  - RPC-literal 
type message part parameters should have a type attribute
org.apache.axis2.description.WSDL11ToAxisServiceBuilder$WSDLProcessingException: 
RPC-literal type message part parameters should have a type attribute
    at 
org.apache.axis2.description.WSDL11ToAxisServiceBuilder.addPartToElement(WSDL11ToAxisServiceBuilder.java:1992)
    at 
org.apache.axis2.description.WSDL11ToAxisServiceBuilder.getNewComplextType(WSDL11ToAxisServiceBuilder.java:1879)
    at 
org.apache.axis2.description.WSDL11ToAxisServiceBuilder.createSchemaForPorttype(WSDL11ToAxisServiceBuilder.java:1544)
    at 
org.apache.axis2.description.WSDL11ToAxisServiceBuilder.generateWrapperSchema(WSDL11ToAxisServiceBuilder.java:1431)
    at 
org.apache.axis2.description.WSDL11ToAxisServiceBuilder.populateService(WSDL11ToAxisServiceBuilder.java:255)
    at 
org.apache.axis2.description.AxisService.createClientSideAxisService(AxisService.java:1644)
    at 
org.apache.axis2.description.AxisService.createClientSideAxisService(AxisService.java:1608)
    at org.apache.axis2.client.ServiceClient.<init>(ServiceClient.java:215)
    at com.fizzback.qa.gates.fake.Client.main(Client.java:56)
... etc.

It is strange for me because similar sample code from inet source is 
working correctly:
    ...
    EndpointReference targetEPR = new 
EndpointReference("http://localhost:8080/axis2/services/MyService");
    OMElement payload = getEchoOMElement();
    Options options = new Options();
    options.setTo(targetEPR);
    options.setAction("urn:echo");
    ServiceClient sender = new ServiceClient();
    sender.setOptions(options);
    OMElement result = sender.sendReceive(payload);
    ...

A WSDL for test service is as follow:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ns0="http://example1.userguide" 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://example1.userguide">
    <wsdl:documentation>MyService</wsdl:documentation>
    <wsdl:types>
        <xs:schema xmlns:ns="http://example1.userguide" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://example1.userguide">
            <xs:complexType name="Exception">
                <xs:sequence>
                    <xs:element minOccurs="0" name="Exception" nillable="true" type="xs:anyType"/>
                </xs:sequence>

            </xs:complexType>
            <xs:element name="XMLStreamException">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element minOccurs="0" name="XMLStreamException" nillable="true" type="xs:anyType"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element name="echo">

                <xs:complexType>
                    <xs:sequence>
                        <xs:element minOccurs="0" name="echo" nillable="true" type="xs:anyType"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element name="echoResponse">
                <xs:complexType>
                    <xs:sequence>

                        <xs:element minOccurs="0" name="return" nillable="true" type="xs:anyType"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element name="ping">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element minOccurs="0" name="ping" nillable="true" type="xs:anyType"/>
                    </xs:sequence>

                </xs:complexType>
            </xs:element>
            <xs:element name="pingF">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element minOccurs="0" name="param0" nillable="true" type="xs:anyType"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>

        </xs:schema>
    </wsdl:types>
    <wsdl:message name="pingFRequest">
        <wsdl:part name="parameters" element="ns0:pingF"/>
    </wsdl:message>
    <wsdl:message name="pingFResponse"/>
    <wsdl:message name="echoRequest">
        <wsdl:part name="parameters" element="ns0:echo"/>
    </wsdl:message>

    <wsdl:message name="echoResponse">
        <wsdl:part name="parameters" element="ns0:echoResponse"/>
    </wsdl:message>
    <wsdl:message name="XMLStreamException">
        <wsdl:part name="parameters" element="ns0:XMLStreamException"/>
    </wsdl:message>
    <wsdl:message name="pingRequest">
        <wsdl:part name="parameters" element="ns0:ping"/>
    </wsdl:message>

    <wsdl:message name="pingResponse"/>
    <wsdl:portType name="MyServicePortType">
        <wsdl:operation name="pingF">
            <wsdl:input message="ns0:pingFRequest" wsaw:Action="urn:pingF"/>
            <wsdl:output message="ns0:pingFResponse" wsaw:Action="urn:pingFResponse"/>
        </wsdl:operation>
        <wsdl:operation name="echo">
            <wsdl:input message="ns0:echoRequest" wsaw:Action="urn:echo"/>
            <wsdl:output message="ns0:echoResponse" wsaw:Action="urn:echoResponse"/>

            <wsdl:fault message="ns0:XMLStreamException" name="XMLStreamException" wsaw:Action="urn:echoXMLStreamException"/>
        </wsdl:operation>
        <wsdl:operation name="ping">
            <wsdl:input message="ns0:pingRequest" wsaw:Action="urn:ping"/>
            <wsdl:output message="ns0:pingResponse" wsaw:Action="urn:pingResponse"/>
            <wsdl:fault message="ns0:XMLStreamException" name="XMLStreamException" wsaw:Action="urn:pingXMLStreamException"/>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="MyServiceSOAP11Binding" type="ns0:MyServicePortType">

        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
        <wsdl:operation name="pingF">
            <soap:operation soapAction="urn:pingF" style="document"/>
            <wsdl:input>
                <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal"/>
            </wsdl:output>

        </wsdl:operation>
        <wsdl:operation name="echo">
            <soap:operation soapAction="urn:echo" style="document"/>
            <wsdl:input>
                <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal"/>
            </wsdl:output>

            <wsdl:fault name="XMLStreamException">
                <soap:fault use="literal" name="XMLStreamException"/>
            </wsdl:fault>
        </wsdl:operation>
        <wsdl:operation name="ping">
            <soap:operation soapAction="urn:ping" style="document"/>
            <wsdl:input>
                <soap:body use="literal"/>
            </wsdl:input>

            <wsdl:output>
                <soap:body use="literal"/>
            </wsdl:output>
            <wsdl:fault name="XMLStreamException">
                <soap:fault use="literal" name="XMLStreamException"/>
            </wsdl:fault>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:binding name="MyServiceSOAP12Binding" type="ns0:MyServicePortType">

        <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
        <wsdl:operation name="pingF">
            <soap12:operation soapAction="urn:pingF" style="document"/>
            <wsdl:input>
                <soap12:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap12:body use="literal"/>
            </wsdl:output>

        </wsdl:operation>
        <wsdl:operation name="echo">
            <soap12:operation soapAction="urn:echo" style="document"/>
            <wsdl:input>
                <soap12:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap12:body use="literal"/>
            </wsdl:output>

            <wsdl:fault name="XMLStreamException">
                <soap12:fault use="literal" name="XMLStreamException"/>
            </wsdl:fault>
        </wsdl:operation>
        <wsdl:operation name="ping">
            <soap12:operation soapAction="urn:ping" style="document"/>
            <wsdl:input>
                <soap12:body use="literal"/>
            </wsdl:input>

            <wsdl:output>
                <soap12:body use="literal"/>
            </wsdl:output>
            <wsdl:fault name="XMLStreamException">
                <soap12:fault use="literal" name="XMLStreamException"/>
            </wsdl:fault>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:binding name="MyServiceHttpBinding" type="ns0:MyServicePortType">

        <http:binding verb="POST"/>
        <wsdl:operation name="pingF">
            <http:operation location="MyService/pingF"/>
            <wsdl:input>
                <mime:content type="text/xml" part="pingF"/>
            </wsdl:input>
        </wsdl:operation>
        <wsdl:operation name="echo">
            <http:operation location="MyService/echo"/>

            <wsdl:input>
                <mime:content type="text/xml" part="echo"/>
            </wsdl:input>
            <wsdl:output>
                <mime:content type="text/xml" part="echo"/>
            </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="ping">
            <http:operation location="MyService/ping"/>

            <wsdl:input>
                <mime:content type="text/xml" part="ping"/>
            </wsdl:input>
            <wsdl:output>
                <mime:content type="text/xml" part="ping"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="MyService">

        <wsdl:port name="MyServiceSOAP11port_http" binding="ns0:MyServiceSOAP11Binding">
            <soap:address location="http://127.0.0.1:8080/axis2/services/MyService"/>
        </wsdl:port>
        <wsdl:port name="MyServiceSOAP12port_http" binding="ns0:MyServiceSOAP12Binding">
            <soap12:address location="http://127.0.0.1:8080/axis2/services/MyService"/>
        </wsdl:port>
        <wsdl:port name="MyServiceHttpport" binding="ns0:MyServiceHttpBinding">
            <http:address location="http://127.0.0.1:8080/axis2/services/MyService"/>
        </wsdl:port>

    </wsdl:service>
</wsdl:definitions>


If you have seen some mistake in my code please tell me. Thanks in advance.

Dima.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: consume WSDL and call WS at runtime

Posted by Dmitry Trunikov <dm...@zoral.com.ua>.
Anne Thomas Manes wrote:
> It sounds like your WSDL is not valid. The error message indicates
> that the service binding specifies RPC/literal, but the message parts
> reference elements rather than types.
>   

Thanks for reply Anne.

> Please post the WSDL.
>
> Anne
>   
Actually I've posted its in previous post :)
>> A WSDL for test service is as follow:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ns0="http://example1.userguide" 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://example1.userguide">
>>     <wsdl:documentation>MyService</wsdl:documentation>
>>     <wsdl:types>
>>         <xs:schema xmlns:ns="http://example1.userguide" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://example1.userguide">
>>             <xs:complexType name="Exception">
>>                 <xs:sequence>
>>                     <xs:element minOccurs="0" name="Exception" nillable="true" type="xs:anyType"/>
>>                 </xs:sequence>
>>
>>             </xs:complexType>
>>             <xs:element name="XMLStreamException">
>>                 <xs:complexType>
>>                     <xs:sequence>
>>                         <xs:element minOccurs="0" name="XMLStreamException" nillable="true" type="xs:anyType"/>
>>                     </xs:sequence>
>>                 </xs:complexType>
>>             </xs:element>
>>             <xs:element name="echo">
>>
>>                 <xs:complexType>
>>                     <xs:sequence>
>>                         <xs:element minOccurs="0" name="echo" nillable="true" type="xs:anyType"/>
>>                     </xs:sequence>
>>                 </xs:complexType>
>>             </xs:element>
>>             <xs:element name="echoResponse">
>>                 <xs:complexType>
>>                     <xs:sequence>
>>
>>                         <xs:element minOccurs="0" name="return" nillable="true" type="xs:anyType"/>
>>                     </xs:sequence>
>>                 </xs:complexType>
>>             </xs:element>
>>             <xs:element name="ping">
>>                 <xs:complexType>
>>                     <xs:sequence>
>>                         <xs:element minOccurs="0" name="ping" nillable="true" type="xs:anyType"/>
>>                     </xs:sequence>
>>
>>                 </xs:complexType>
>>             </xs:element>
>>             <xs:element name="pingF">
>>                 <xs:complexType>
>>                     <xs:sequence>
>>                         <xs:element minOccurs="0" name="param0" nillable="true" type="xs:anyType"/>
>>                     </xs:sequence>
>>                 </xs:complexType>
>>             </xs:element>
>>
>>         </xs:schema>
>>     </wsdl:types>
>>     <wsdl:message name="pingFRequest">
>>         <wsdl:part name="parameters" element="ns0:pingF"/>
>>     </wsdl:message>
>>     <wsdl:message name="pingFResponse"/>
>>     <wsdl:message name="echoRequest">
>>         <wsdl:part name="parameters" element="ns0:echo"/>
>>     </wsdl:message>
>>
>>     <wsdl:message name="echoResponse">
>>         <wsdl:part name="parameters" element="ns0:echoResponse"/>
>>     </wsdl:message>
>>     <wsdl:message name="XMLStreamException">
>>         <wsdl:part name="parameters" element="ns0:XMLStreamException"/>
>>     </wsdl:message>
>>     <wsdl:message name="pingRequest">
>>         <wsdl:part name="parameters" element="ns0:ping"/>
>>     </wsdl:message>
>>
>>     <wsdl:message name="pingResponse"/>
>>     <wsdl:portType name="MyServicePortType">
>>         <wsdl:operation name="pingF">
>>             <wsdl:input message="ns0:pingFRequest" wsaw:Action="urn:pingF"/>
>>             <wsdl:output message="ns0:pingFResponse" wsaw:Action="urn:pingFResponse"/>
>>         </wsdl:operation>
>>         <wsdl:operation name="echo">
>>             <wsdl:input message="ns0:echoRequest" wsaw:Action="urn:echo"/>
>>             <wsdl:output message="ns0:echoResponse" wsaw:Action="urn:echoResponse"/>
>>
>>             <wsdl:fault message="ns0:XMLStreamException" name="XMLStreamException" wsaw:Action="urn:echoXMLStreamException"/>
>>         </wsdl:operation>
>>         <wsdl:operation name="ping">
>>             <wsdl:input message="ns0:pingRequest" wsaw:Action="urn:ping"/>
>>             <wsdl:output message="ns0:pingResponse" wsaw:Action="urn:pingResponse"/>
>>             <wsdl:fault message="ns0:XMLStreamException" name="XMLStreamException" wsaw:Action="urn:pingXMLStreamException"/>
>>         </wsdl:operation>
>>     </wsdl:portType>
>>     <wsdl:binding name="MyServiceSOAP11Binding" type="ns0:MyServicePortType">
>>
>>         <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
>>         <wsdl:operation name="pingF">
>>             <soap:operation soapAction="urn:pingF" style="document"/>
>>             <wsdl:input>
>>                 <soap:body use="literal"/>
>>             </wsdl:input>
>>             <wsdl:output>
>>                 <soap:body use="literal"/>
>>             </wsdl:output>
>>
>>         </wsdl:operation>
>>         <wsdl:operation name="echo">
>>             <soap:operation soapAction="urn:echo" style="document"/>
>>             <wsdl:input>
>>                 <soap:body use="literal"/>
>>             </wsdl:input>
>>             <wsdl:output>
>>                 <soap:body use="literal"/>
>>             </wsdl:output>
>>
>>             <wsdl:fault name="XMLStreamException">
>>                 <soap:fault use="literal" name="XMLStreamException"/>
>>             </wsdl:fault>
>>         </wsdl:operation>
>>         <wsdl:operation name="ping">
>>             <soap:operation soapAction="urn:ping" style="document"/>
>>             <wsdl:input>
>>                 <soap:body use="literal"/>
>>             </wsdl:input>
>>
>>             <wsdl:output>
>>                 <soap:body use="literal"/>
>>             </wsdl:output>
>>             <wsdl:fault name="XMLStreamException">
>>                 <soap:fault use="literal" name="XMLStreamException"/>
>>             </wsdl:fault>
>>         </wsdl:operation>
>>     </wsdl:binding>
>>     <wsdl:binding name="MyServiceSOAP12Binding" type="ns0:MyServicePortType">
>>
>>         <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
>>         <wsdl:operation name="pingF">
>>             <soap12:operation soapAction="urn:pingF" style="document"/>
>>             <wsdl:input>
>>                 <soap12:body use="literal"/>
>>             </wsdl:input>
>>             <wsdl:output>
>>                 <soap12:body use="literal"/>
>>             </wsdl:output>
>>
>>         </wsdl:operation>
>>         <wsdl:operation name="echo">
>>             <soap12:operation soapAction="urn:echo" style="document"/>
>>             <wsdl:input>
>>                 <soap12:body use="literal"/>
>>             </wsdl:input>
>>             <wsdl:output>
>>                 <soap12:body use="literal"/>
>>             </wsdl:output>
>>
>>             <wsdl:fault name="XMLStreamException">
>>                 <soap12:fault use="literal" name="XMLStreamException"/>
>>             </wsdl:fault>
>>         </wsdl:operation>
>>         <wsdl:operation name="ping">
>>             <soap12:operation soapAction="urn:ping" style="document"/>
>>             <wsdl:input>
>>                 <soap12:body use="literal"/>
>>             </wsdl:input>
>>
>>             <wsdl:output>
>>                 <soap12:body use="literal"/>
>>             </wsdl:output>
>>             <wsdl:fault name="XMLStreamException">
>>                 <soap12:fault use="literal" name="XMLStreamException"/>
>>             </wsdl:fault>
>>         </wsdl:operation>
>>     </wsdl:binding>
>>     <wsdl:binding name="MyServiceHttpBinding" type="ns0:MyServicePortType">
>>
>>         <http:binding verb="POST"/>
>>         <wsdl:operation name="pingF">
>>             <http:operation location="MyService/pingF"/>
>>             <wsdl:input>
>>                 <mime:content type="text/xml" part="pingF"/>
>>             </wsdl:input>
>>         </wsdl:operation>
>>         <wsdl:operation name="echo">
>>             <http:operation location="MyService/echo"/>
>>
>>             <wsdl:input>
>>                 <mime:content type="text/xml" part="echo"/>
>>             </wsdl:input>
>>             <wsdl:output>
>>                 <mime:content type="text/xml" part="echo"/>
>>             </wsdl:output>
>>         </wsdl:operation>
>>         <wsdl:operation name="ping">
>>             <http:operation location="MyService/ping"/>
>>
>>             <wsdl:input>
>>                 <mime:content type="text/xml" part="ping"/>
>>             </wsdl:input>
>>             <wsdl:output>
>>                 <mime:content type="text/xml" part="ping"/>
>>             </wsdl:output>
>>         </wsdl:operation>
>>     </wsdl:binding>
>>     <wsdl:service name="MyService">
>>
>>         <wsdl:port name="MyServiceSOAP11port_http" binding="ns0:MyServiceSOAP11Binding">
>>             <soap:address location="http://127.0.0.1:8080/axis2/services/MyService"/>
>>         </wsdl:port>
>>         <wsdl:port name="MyServiceSOAP12port_http" binding="ns0:MyServiceSOAP12Binding">
>>             <soap12:address location="http://127.0.0.1:8080/axis2/services/MyService"/>
>>         </wsdl:port>
>>         <wsdl:port name="MyServiceHttpport" binding="ns0:MyServiceHttpBinding">
>>             <http:address location="http://127.0.0.1:8080/axis2/services/MyService"/>
>>         </wsdl:port>
>>
>>     </wsdl:service>
>> </wsdl:definitions>
>>
>>
>> If you have seen some mistake in my code please tell me. Thanks in advance.
>>
>> Dima.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>
>>
>>     
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: consume WSDL and call WS at runtime

Posted by Anne Thomas Manes <at...@gmail.com>.
It sounds like your WSDL is not valid. The error message indicates
that the service binding specifies RPC/literal, but the message parts
reference elements rather than types.

Please post the WSDL.

Anne

On Nov 20, 2007 7:14 AM, Dmitry Trunikov <dm...@zoral.com.ua> wrote:
> Dear ALL!
>
> There is trivial sample code which is not running in some reason. Please
> point me where is a bug.
> Application should retrieve WSDL by URL and call method from that WS.
> Code snippet:
>
> import java.net.URL;
> import javax.xml.namespace.QName;
> import org.apache.axiom.om.OMAbstractFactory;
> import org.apache.axiom.om.OMElement;
> import org.apache.axiom.om.OMFactory;
> import org.apache.axiom.om.OMNamespace;
> import org.apache.axis2.client.Options;
> import org.apache.axis2.client.ServiceClient;
> import org.apache.axis2.context.ConfigurationContext;
> import org.apache.axis2.engine.AxisConfiguration;
>
> public class Client {
>     public static void main(String[] argv) {
>         try {
>             ServiceClient client = new ServiceClient(
>                     null,
>                     new
> URL("http://127.0.0.1:8080/axis2/services/MyService?wsdl"),
>                     new QName("http://example1.userguide", "MyService"),
>                     "MyServiceHttpport"
>                     );
>             OMFactory fac = OMAbstractFactory.getOMFactory();
>             OMNamespace omNs =
> fac.createOMNamespace("http://example1.userguide", "ns1");
>             OMElement method = fac.createOMElement("echo", omNs);
>             OMElement value = fac.createOMElement("value", omNs);
>             value.setText("Hello , my first service utilization");
>             method.addChild(value);
>             OMElement result = client.sendReceive(method);
>             System.out.println(result);
>         } catch (Throwable th) {
>             th.printStackTrace();
>         }
>     }
> }
>
> Unfortunately it throws runtime error:
>
> 2007-11-20 13:43:02,632 ERROR
> org.apache.axis2.description.WSDL11ToAxisServiceBuilder  - RPC-literal
> type message part parameters should have a type attribute
> org.apache.axis2.description.WSDL11ToAxisServiceBuilder$WSDLProcessingException:
> RPC-literal type message part parameters should have a type attribute
>     at
> org.apache.axis2.description.WSDL11ToAxisServiceBuilder.addPartToElement(WSDL11ToAxisServiceBuilder.java:1992)
>     at
> org.apache.axis2.description.WSDL11ToAxisServiceBuilder.getNewComplextType(WSDL11ToAxisServiceBuilder.java:1879)
>     at
> org.apache.axis2.description.WSDL11ToAxisServiceBuilder.createSchemaForPorttype(WSDL11ToAxisServiceBuilder.java:1544)
>     at
> org.apache.axis2.description.WSDL11ToAxisServiceBuilder.generateWrapperSchema(WSDL11ToAxisServiceBuilder.java:1431)
>     at
> org.apache.axis2.description.WSDL11ToAxisServiceBuilder.populateService(WSDL11ToAxisServiceBuilder.java:255)
>     at
> org.apache.axis2.description.AxisService.createClientSideAxisService(AxisService.java:1644)
>     at
> org.apache.axis2.description.AxisService.createClientSideAxisService(AxisService.java:1608)
>     at org.apache.axis2.client.ServiceClient.<init>(ServiceClient.java:215)
>     at com.fizzback.qa.gates.fake.Client.main(Client.java:56)
> ... etc.
>
> It is strange for me because similar sample code from inet source is
> working correctly:
>     ...
>     EndpointReference targetEPR = new
> EndpointReference("http://localhost:8080/axis2/services/MyService");
>     OMElement payload = getEchoOMElement();
>     Options options = new Options();
>     options.setTo(targetEPR);
>     options.setAction("urn:echo");
>     ServiceClient sender = new ServiceClient();
>     sender.setOptions(options);
>     OMElement result = sender.sendReceive(payload);
>     ...
>
> A WSDL for test service is as follow:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ns0="http://example1.userguide" 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://example1.userguide">
>     <wsdl:documentation>MyService</wsdl:documentation>
>     <wsdl:types>
>         <xs:schema xmlns:ns="http://example1.userguide" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://example1.userguide">
>             <xs:complexType name="Exception">
>                 <xs:sequence>
>                     <xs:element minOccurs="0" name="Exception" nillable="true" type="xs:anyType"/>
>                 </xs:sequence>
>
>             </xs:complexType>
>             <xs:element name="XMLStreamException">
>                 <xs:complexType>
>                     <xs:sequence>
>                         <xs:element minOccurs="0" name="XMLStreamException" nillable="true" type="xs:anyType"/>
>                     </xs:sequence>
>                 </xs:complexType>
>             </xs:element>
>             <xs:element name="echo">
>
>                 <xs:complexType>
>                     <xs:sequence>
>                         <xs:element minOccurs="0" name="echo" nillable="true" type="xs:anyType"/>
>                     </xs:sequence>
>                 </xs:complexType>
>             </xs:element>
>             <xs:element name="echoResponse">
>                 <xs:complexType>
>                     <xs:sequence>
>
>                         <xs:element minOccurs="0" name="return" nillable="true" type="xs:anyType"/>
>                     </xs:sequence>
>                 </xs:complexType>
>             </xs:element>
>             <xs:element name="ping">
>                 <xs:complexType>
>                     <xs:sequence>
>                         <xs:element minOccurs="0" name="ping" nillable="true" type="xs:anyType"/>
>                     </xs:sequence>
>
>                 </xs:complexType>
>             </xs:element>
>             <xs:element name="pingF">
>                 <xs:complexType>
>                     <xs:sequence>
>                         <xs:element minOccurs="0" name="param0" nillable="true" type="xs:anyType"/>
>                     </xs:sequence>
>                 </xs:complexType>
>             </xs:element>
>
>         </xs:schema>
>     </wsdl:types>
>     <wsdl:message name="pingFRequest">
>         <wsdl:part name="parameters" element="ns0:pingF"/>
>     </wsdl:message>
>     <wsdl:message name="pingFResponse"/>
>     <wsdl:message name="echoRequest">
>         <wsdl:part name="parameters" element="ns0:echo"/>
>     </wsdl:message>
>
>     <wsdl:message name="echoResponse">
>         <wsdl:part name="parameters" element="ns0:echoResponse"/>
>     </wsdl:message>
>     <wsdl:message name="XMLStreamException">
>         <wsdl:part name="parameters" element="ns0:XMLStreamException"/>
>     </wsdl:message>
>     <wsdl:message name="pingRequest">
>         <wsdl:part name="parameters" element="ns0:ping"/>
>     </wsdl:message>
>
>     <wsdl:message name="pingResponse"/>
>     <wsdl:portType name="MyServicePortType">
>         <wsdl:operation name="pingF">
>             <wsdl:input message="ns0:pingFRequest" wsaw:Action="urn:pingF"/>
>             <wsdl:output message="ns0:pingFResponse" wsaw:Action="urn:pingFResponse"/>
>         </wsdl:operation>
>         <wsdl:operation name="echo">
>             <wsdl:input message="ns0:echoRequest" wsaw:Action="urn:echo"/>
>             <wsdl:output message="ns0:echoResponse" wsaw:Action="urn:echoResponse"/>
>
>             <wsdl:fault message="ns0:XMLStreamException" name="XMLStreamException" wsaw:Action="urn:echoXMLStreamException"/>
>         </wsdl:operation>
>         <wsdl:operation name="ping">
>             <wsdl:input message="ns0:pingRequest" wsaw:Action="urn:ping"/>
>             <wsdl:output message="ns0:pingResponse" wsaw:Action="urn:pingResponse"/>
>             <wsdl:fault message="ns0:XMLStreamException" name="XMLStreamException" wsaw:Action="urn:pingXMLStreamException"/>
>         </wsdl:operation>
>     </wsdl:portType>
>     <wsdl:binding name="MyServiceSOAP11Binding" type="ns0:MyServicePortType">
>
>         <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
>         <wsdl:operation name="pingF">
>             <soap:operation soapAction="urn:pingF" style="document"/>
>             <wsdl:input>
>                 <soap:body use="literal"/>
>             </wsdl:input>
>             <wsdl:output>
>                 <soap:body use="literal"/>
>             </wsdl:output>
>
>         </wsdl:operation>
>         <wsdl:operation name="echo">
>             <soap:operation soapAction="urn:echo" style="document"/>
>             <wsdl:input>
>                 <soap:body use="literal"/>
>             </wsdl:input>
>             <wsdl:output>
>                 <soap:body use="literal"/>
>             </wsdl:output>
>
>             <wsdl:fault name="XMLStreamException">
>                 <soap:fault use="literal" name="XMLStreamException"/>
>             </wsdl:fault>
>         </wsdl:operation>
>         <wsdl:operation name="ping">
>             <soap:operation soapAction="urn:ping" style="document"/>
>             <wsdl:input>
>                 <soap:body use="literal"/>
>             </wsdl:input>
>
>             <wsdl:output>
>                 <soap:body use="literal"/>
>             </wsdl:output>
>             <wsdl:fault name="XMLStreamException">
>                 <soap:fault use="literal" name="XMLStreamException"/>
>             </wsdl:fault>
>         </wsdl:operation>
>     </wsdl:binding>
>     <wsdl:binding name="MyServiceSOAP12Binding" type="ns0:MyServicePortType">
>
>         <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
>         <wsdl:operation name="pingF">
>             <soap12:operation soapAction="urn:pingF" style="document"/>
>             <wsdl:input>
>                 <soap12:body use="literal"/>
>             </wsdl:input>
>             <wsdl:output>
>                 <soap12:body use="literal"/>
>             </wsdl:output>
>
>         </wsdl:operation>
>         <wsdl:operation name="echo">
>             <soap12:operation soapAction="urn:echo" style="document"/>
>             <wsdl:input>
>                 <soap12:body use="literal"/>
>             </wsdl:input>
>             <wsdl:output>
>                 <soap12:body use="literal"/>
>             </wsdl:output>
>
>             <wsdl:fault name="XMLStreamException">
>                 <soap12:fault use="literal" name="XMLStreamException"/>
>             </wsdl:fault>
>         </wsdl:operation>
>         <wsdl:operation name="ping">
>             <soap12:operation soapAction="urn:ping" style="document"/>
>             <wsdl:input>
>                 <soap12:body use="literal"/>
>             </wsdl:input>
>
>             <wsdl:output>
>                 <soap12:body use="literal"/>
>             </wsdl:output>
>             <wsdl:fault name="XMLStreamException">
>                 <soap12:fault use="literal" name="XMLStreamException"/>
>             </wsdl:fault>
>         </wsdl:operation>
>     </wsdl:binding>
>     <wsdl:binding name="MyServiceHttpBinding" type="ns0:MyServicePortType">
>
>         <http:binding verb="POST"/>
>         <wsdl:operation name="pingF">
>             <http:operation location="MyService/pingF"/>
>             <wsdl:input>
>                 <mime:content type="text/xml" part="pingF"/>
>             </wsdl:input>
>         </wsdl:operation>
>         <wsdl:operation name="echo">
>             <http:operation location="MyService/echo"/>
>
>             <wsdl:input>
>                 <mime:content type="text/xml" part="echo"/>
>             </wsdl:input>
>             <wsdl:output>
>                 <mime:content type="text/xml" part="echo"/>
>             </wsdl:output>
>         </wsdl:operation>
>         <wsdl:operation name="ping">
>             <http:operation location="MyService/ping"/>
>
>             <wsdl:input>
>                 <mime:content type="text/xml" part="ping"/>
>             </wsdl:input>
>             <wsdl:output>
>                 <mime:content type="text/xml" part="ping"/>
>             </wsdl:output>
>         </wsdl:operation>
>     </wsdl:binding>
>     <wsdl:service name="MyService">
>
>         <wsdl:port name="MyServiceSOAP11port_http" binding="ns0:MyServiceSOAP11Binding">
>             <soap:address location="http://127.0.0.1:8080/axis2/services/MyService"/>
>         </wsdl:port>
>         <wsdl:port name="MyServiceSOAP12port_http" binding="ns0:MyServiceSOAP12Binding">
>             <soap12:address location="http://127.0.0.1:8080/axis2/services/MyService"/>
>         </wsdl:port>
>         <wsdl:port name="MyServiceHttpport" binding="ns0:MyServiceHttpBinding">
>             <http:address location="http://127.0.0.1:8080/axis2/services/MyService"/>
>         </wsdl:port>
>
>     </wsdl:service>
> </wsdl:definitions>
>
>
> If you have seen some mistake in my code please tell me. Thanks in advance.
>
> Dima.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org