List Info

Thread: XSUL Dynamic Invoker Problem with .NET




XSUL Dynamic Invoker Problem with .NET
user name
2006-10-31 17:52:19
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&gt;keyboard&lt;/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 xmlnssd=' http://www.w3.org/2001/XMLSchema' xmlnssi=' 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>
&nbsp; &nbsp;  <wsa:To>http://localhost/GetPrice/Service.asmx</wsa:To>
 &nbsp; &nbsp; <wsa:Action> http://tempuri.org//ServiceSoap/getPrice&lt;/wsa:Action>
&nbsp; </S:Header>
&nbsp; <S:Body>
 &nbsp; &nbsp; <n1:item xmlns:n1=' http://tempuri.org/' />
  </S:Body>
<;/S:Envelope>



############### WSDL ################
&nbsp; <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?>
- < wsdl:types&gt;
- < s:schema elementFormDefault ="qualified&quot; targetNamespace=&quot;http://tempuri.org/"&gt;
- < s:element name =&quot;item"&gt;
- < s:complexType>
- < s:sequence&gt;
  <s:element minOccurs="0 " maxOccurs="1" name=&quot;item" type=&quot;s:string" />
 ; </s:sequence&gt;
&nbsp; </s:complexType>
  </s:element&gt;
- < s:element name =&quot;getPriceResponse"&gt;
- < s:complexType>
- < s:sequence&gt;
  <s:element minOccurs="1 " maxOccurs="1" name=&quot;getPriceResult&quot; type=&quot;s:double" />
 ; </s:sequence&gt;
&nbsp; </s:complexType>
  </s:element&gt;
&nbsp; </s:schema>;
&nbsp; </wsdl:types&gt;
- < wsdl:message name =&quot;getPriceSoapIn">;
  <wsdl:part name=&quot;parameters &quot; element="tns:item&quot; />
 ; </wsdl:message>
- < wsdl:message name =&quot;getPriceSoapOut"&gt;
  <wsdl:part name=&quot;parameters &quot; element="tns:getPriceResponse&quot; />
 ; </wsdl:message>
- < wsdl:portType name =&quot;ServiceSoap&quot;>
+ < wsdl:operation name =&quot;getPrice">
  <wsdl:input message="tns:getPriceSoapIn &quot; />
  <wsdl:output message="tns:getPriceSoapOut &quot; />
 ; </wsdl:operation>
  </wsdl:portType>
- < wsdl:binding name =&quot;ServiceSoap&quot; type=&quot;tns:ServiceSoap"&gt;
  <soap:binding transport=" http://schemas.xmlsoap.org/soap/http&quot; />
- < wsdl:operation name =&quot;getPrice">
  <soap:operation soapAction=" http://tempuri.org/getPrice" style=&quot;document" />
- < wsdl:input&gt;
  <soap:body use=&quot;literal " />
&nbsp; </wsdl:input&gt;
- < wsdl:output>
  <soap:body use=&quot;literal " />
&nbsp; </wsdl:output>
  </wsdl:operation>
  </wsdl:binding>
- < wsdl:binding name =&quot;ServiceSoap12&quot; type=&quot;tns:ServiceSoap"&gt;
  <soap12:binding transport=" http://schemas.xmlsoap.org/soap/http&quot; />
- < wsdl:operation name =&quot;getPrice">
  <soap12:operation soapAction=" http://tempuri.org/getPrice" style=&quot;document" />
- < wsdl:input&gt;
  <soap12:body use=&quot;literal " />
 ; </wsdl:input&gt;
- < wsdl:output>
  <soap12:body use=&quot;literal " />
 ; </wsdl:output>
  </wsdl:operation>
  </wsdl:binding>
- < wsdl:service name =&quot;Service">
- < wsdl:port name =&quot;ServiceSoap&quot; binding="tns:ServiceSoap">
  <soap:address location=" http://localhost/GetPrice/Service.asmx" />
 ; </wsdl:port&gt;
- < wsdl:port name =&quot;ServiceSoap12&quot; binding="tns:ServiceSoap12";>
  <soap12:address location=" http://localhost/GetPrice/Service.asmx" />
 ; </wsdl:port&gt;
&nbsp; </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 {
 &nbsp;  private final static MLogger logger = MLogger.getLogger();
  ;  private final static XmlInfosetBuilder builder = XmlConstants.BUILDER ;
 &nbsp; 
 &nbsp;  private static void usage(String errMsg) {
 &nbsp; &nbsp;   ; System.err.println(&quot;Usage: {WSDL URL} {operation name} [parameters ...]");
 &nbsp;  }

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

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

 &nbsp;   ; &nbsp; String wsdlLoc = args[0];

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

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

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

 &nbsp; &nbsp; &nbsp;  WSIFPort port = serv.getPort(portName);

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

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

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

about | contact  Other archives ( Real Estate discussion Medical topics )