Java – How to create Axis Client without wsdl’s url


I want to create an Axis client for a web service with local wsdl, without knowing the wsdl's url. I've tried the Dynamic Invocation Interface method as in this tutorial but I get the following error:

AxisFault faultCode:
faultSubcode: faultString: No client
transport named 'null' found!
faultActor: faultNode: faultDetail:
client transport named 'null' found!

My code is:

        ServiceFactory factory = ServiceFactory.newInstance();
        Service service = factory.createService(new QName("","ComposedWebServiceServiceService"));
        Call call = service.createCall();
        call.setPortTypeName(new QName("","ComposedWebServiceServicePortType"));
        call.setProperty(Call.OPERATION_STYLE_PROPERTY, "wrapped");
        call.setProperty(Call.ENCODINGSTYLE_URI_PROPERTY, "");
        call.setOperationName(new QName("", "ComposedWebServiceServiceOperation"));
        call.addParameter("input1", XMLType.XSD_STRING, ParameterMode.IN);
        String[] params = {input};
        response = (String)call.invoke(params);

Thank you

Best Solution

I had the same problem as yours. After digging for hours, it seems like I've almost solved this problem. This exception occurs because of missing set target endpoint address Here is my code

        Call call = service.createCall();
        call.setOperationName(new QName(namespace, operation));
        call.setProperty(Call.ENCODINGSTYLE_URI_PROPERTY, ""); 
        call.setProperty(Call.OPERATION_STYLE_PROPERTY, "rpc");
        call.addParameter("in0", org.apache.axis.Constants.XSD_STRING ,ParameterMode.IN);
        call.addParameter("in1", org.apache.axis.Constants.XSD_STRING ,ParameterMode.IN);
        String targetEndpoint = "";
        String result = (String) call.invoke(params);

The value of targetEndpoint agument is the value of location attribute of address element inside port element. Here is an example

<service name="WeatherForecastTest1Service">
    <port binding="impl:WeatherForecastTest1SoapBinding" name="WeatherForecastTest1">
      <wsdlsoap:address location=""/>

You can get this value by retrieving wsdl document using some wsdlParser (I use Axis's WSDL4J) (Note that in the code example above, I have hardcoded the targetEndpoint value)

Moreover, I set OPERATION_STYLE_PROPERTY to rpc style and ENCODINGSTYLE_URI_PROPERTY to (this is default value) Here is the document I found to solve this problem

Hope that help you! Sorry for my bad English.

Related Question