Hello list!

I got the latest xsul library(2.7.9), and everything is working fine when dynamic invoking some web services (deployed in axis, phpnusoap, websphere), except for the Document/Literal Wrapped .NET Web Services.

With the logging utility enabled, I can see that the SOAP envelope is not sending the parameters correctly when the service is in .NET!

My args are http://localhost/GetPrice/Service.asmx?WSDL  getPrice  keyboard

The envelope is incorrect (in bold), the value of "item" is not included (should be <item>keyboard</item> isn't it?). I'm also attaching the .wsdl of the .NET service, and the .java of xsul dynamic invoker (without the selftest and stuff).

Thanks in advance for any help!

Best regards,

Andre


############### ENVELOPE ################
<?xml version='1.0' encoding='utf-8'?>
<S:Envelope xmlns:xsd=' http://www.w3.org/2001/XMLSchema' xmlns:xsi=' http://www.w3.org/2001/XMLSchema-instance' xmlns:wsa=' http://www.w3.org/2005/08/addressing' xmlns:wsp='http://schemas.xmlsoap.org/ws/2002/12/policy ' xmlns:S='http://schemas.xmlsoap.org/soap/envelope/' >
  <S:Header>
     <wsa:To>http://localhost/GetPrice/Service.asmx</wsa:To>
     <wsa:Action> http://tempuri.org//ServiceSoap/getPrice</wsa:Action>
  </S:Header>
  <S:Body>
     <n1:item xmlns:n1=' http://tempuri.org/' />
  </S:Body>
</S:Envelope>



############### WSDL ################
  <?xml version="1.0" encoding="utf-8" ?>
- < wsdl:definitions xmlns:soap ="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm =" http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc =" http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime =" http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns=" http://tempuri.org/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12 ="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http =" http://schemas.xmlsoap.org/wsdl/http/" targetNamespace=" http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
- < wsdl:types>
- < s:schema elementFormDefault ="qualified" targetNamespace="http://tempuri.org/">
- < s:element name ="item">
- < s:complexType>
- < s:sequence>
  <s:element minOccurs="0 " maxOccurs="1" name="item" type="s:string" />
  </s:sequence>
  </s:complexType>
  </s:element>
- < s:element name ="getPriceResponse">
- < s:complexType>
- < s:sequence>
  <s:element minOccurs="1 " maxOccurs="1" name="getPriceResult" type="s:double" />
  </s:sequence>
  </s:complexType>
  </s:element>
  </s:schema>
  </wsdl:types>
- < wsdl:message name ="getPriceSoapIn">
  <wsdl:part name="parameters " element="tns:item" />
  </wsdl:message>
- < wsdl:message name ="getPriceSoapOut">
  <wsdl:part name="parameters " element="tns:getPriceResponse" />
  </wsdl:message>
- < wsdl:portType name ="ServiceSoap">
+ < wsdl:operation name ="getPrice">
  <wsdl:input message="tns:getPriceSoapIn " />
  <wsdl:output message="tns:getPriceSoapOut " />
  </wsdl:operation>
  </wsdl:portType>
- < wsdl:binding name ="ServiceSoap" type="tns:ServiceSoap">
  <soap:binding transport=" http://schemas.xmlsoap.org/soap/http" />
- < wsdl:operation name ="getPrice">
  <soap:operation soapAction=" http://tempuri.org/getPrice" 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 ="ServiceSoap12" type="tns:ServiceSoap">
  <soap12:binding transport=" http://schemas.xmlsoap.org/soap/http" />
- < wsdl:operation name ="getPrice">
  <soap12:operation soapAction=" http://tempuri.org/getPrice" style="document" />
- < wsdl:input>
  <soap12:body use="literal " />
  </wsdl:input>
- < wsdl:output>
  <soap12:body use="literal " />
  </wsdl:output>
  </wsdl:operation>
  </wsdl:binding>
- < wsdl:service name ="Service">
- < wsdl:port name ="ServiceSoap" binding="tns:ServiceSoap">
  <soap:address location=" http://localhost/GetPrice/Service.asmx" />
  </wsdl:port>
- < wsdl:port name ="ServiceSoap12" binding="tns:ServiceSoap12">
  <soap12:address location=" http://localhost/GetPrice/Service.asmx" />
  </wsdl:port>
  </wsdl:service>
  </wsdl:definitions>






######################## JAVA #########################

import java.io.File ;
import java.net.URI;
import java.util.Iterator;
import java.util.List;
import javax.xml.namespace.QName;
import org.xmlpull.v1.builder.XmlElement;
import org.xmlpull.v1.builder.XmlInfosetBuilder;
import xsul.MLogger;
import xsul.XmlConstants;
import xsul.wsdl.WsdlBindingOperation;
import xsul.wsdl.WsdlDefinitions;
import xsul.wsdl.WsdlMessage;
import xsul.wsdl.WsdlPortTypeOperation;
import xsul.wsdl.WsdlResolver ;
import xsul.wsif.WSIFException;
import xsul.wsif.WSIFMessage;
import xsul.wsif.WSIFOperation;
import xsul.wsif.WSIFPort;
import xsul.wsif.WSIFService;
import xsul.wsif.WSIFServiceFactory;
import xsul.wsif.impl.WSIFMessageElement ;
import xsul.wsif.spi.WSIFProviderManager;

public class XsulDynamicInvoker {
    private final static MLogger logger = MLogger.getLogger();
    private final static XmlInfosetBuilder builder = XmlConstants.BUILDER ;
   
    private static void usage(String errMsg) {
        System.err.println("Usage: {WSDL URL} {operation name} [parameters ...]");
    }

    public static void main(String[] args) throws Exception
    {
        System.err.println("Starting "+XsulDynamicInvoker.class.getName());
        WSIFProviderManager.getInstance().addProvider( new xsul.wsif_xsul_soap_http.Provider() );
        runClient(args);
    }

    private static void runClient(String[] args) throws Exception {
        URI base = ((new File(".")).toURI());
       
        if(args.length < 2) {
            usage("at least two argument required");
        }

        String wsdlLoc = args[0];

        String opName = args[1];
        String portName = null;
        if(opName.charAt(0) == '{') {
            int pos = opName.indexOf('}');
            portName = opName.substring(1, pos);
            opName = opName.substring(pos+1);
        }

        System.err.println("invoking operation '"+opName+"' using WSDL from "+wsdlLoc);
        //log everything!
        MLogger.setCmdNames(":ALL");
        WsdlDefinitions def = WsdlResolver.getInstance().loadWsdl(base, new URI(wsdlLoc));

        WSIFServiceFactory wsf = WSIFServiceFactory.newInstance();
        WSIFService serv = wsf.getService(def);

        WSIFPort port = serv.getPort(portName);

        WSIFOperation op = port.createOperation(opName);
        WSIFMessage in = op.createInputMessage();
       
        WsdlBindingOperation bindingOp =  op.getBindingOperation();
        WsdlPortTypeOperation portTypeOp = bindingOp.lookupOperation();
        WsdlMessage inputMsg = portTypeOp.getInput().lookupMessage();
        Iterator partNames = in.partNames().iterator();

        int count = 2;
        while(partNames.hasNext()) {
            //determine type of argument
            String partName = (String) partNames.next (); //partNames.get(i-2);
            if(count < args.length) {
                String partValue = args[count];
                System.err.println(partName+"="+partValue);
                in.setObjectPart (partName, partValue);
            } else {
                // will try to do some defaulting
                QName type = ((WSIFMessageElement)in).getPartType(partName);
               
                String localPart = type.getLocalPart();
                if("string".equals(localPart)) {
                    in.setObjectPart(partName, "foo string");
                    System.err.println("defaulting "+partName+"="+in.getObjectPart(partName));
                } else if("anyURI".equals(localPart)) {
                    in.setObjectPart(partName, "gsiftp://rainier//tmp/foo.txt");
                    System.err.println("defaulting "+partName+"="+in.getObjectPart(partName));
                } else if("URIArrayType".equals(localPart)) {
                    XmlElement arrayEl = builder.newFragment(partName);
                    arrayEl.addElement("value").addChild("gsiftp://rainier//tmp/foo.txt");
                     in.setObjectPart(partName, arrayEl);
                    System.err.println("defaulting "+partName+"="+in.getObjectPart(partName));
                }
            }
            ++count;
        }

        if(op.isRequestResponseOperation()) {
            WSIFMessage out = op.createOutputMessage();
            WSIFMessage fault = op.createFaultMessage();
            boolean succes = op.executeRequestResponseOperation(in, out, fault);
            if(succes) {
                System.out.println("received response "+out);
            } else {
                System.err.println("received fault "+fault);
            }
        } else {
            op.executeInputOnlyOperation(in);
            System.out.println("input only message was sent successfully");
        }
    }
}

Reply via email to