[xgws-user] XSUL Dynamic Invoker Problem with .NET
Aleksander Slominski
aslom_at_cs.indiana.edu
Tue, 31 Oct 2006 13:56:47 -0500
This is a multi-part message in MIME format.
--------------090709020307080701020109
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
hi Andre,
please when you send WSDL to use for testing send it as attachment - i
had to do plenty of editing to get working WSDL to reproduce the problem.
more below.
André Piazza wrote:
> 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?).
your schema has elementFormDefault ="*qualified*" so item has to be in
schema namespace as it is
> I'm also attaching the .wsdl of the .NET service, and the .java of
> xsul dynamic invoker (without the selftest and stuff).
your input message (getPriceSoapIn) is <item> and you have it optional
(?!) - that is what is sent when getPrice operation is used - it does
not really make sense to me .as it is generally required to have _some_
input message - i have seen empty input and return message but still
there was some message and never optional ...
instead i think you should define getPrice element and have optional
item inside - see attached WSDL to see it.
the input parameter is optional so it can not be set by
XsulDynamicInvoker (DII is really simple command line tester to show API
but more sophisticated command line options would be required to support
XML as input, optional parameters etc) still you can force setting it by
adding right element to input message - for example (you could modify
command line parsing logic to support name=value to set it):
{
WSIFMessageElement inputMessage = ((WSIFMessageElement)in);
XmlNamespace ns = inputMessage.getNamespace(); // it is
qualified - children element must have namespace
inputMessage.addElement(ns, "item").addChild("keyboard");
}
best,
alek
ps. here is modified DII i used and below is output
/* -*- mode: Java; c-basic-offset: 4; indent-tabs-mode: nil; -*-
//------100-columns-wide------>|*/
/*
* Copyright (c) 2005 Extreme! Lab, Indiana University. All rights reserved.
*
* This software is open source. See the bottom of this file for the
licence.
*
* $Id: XsulDynamicInvoker.java,v 1.5 2006/05/24 06:50:10 aslom Exp $
*/
package xsul.dii;
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 org.xmlpull.v1.builder.XmlNamespace;
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() );
if(args.length > 0 && args[0].equals("selftest")) {
String GOOGLE_KEY = "google.key";
String googleKey = System.getProperty(GOOGLE_KEY); //
if(googleKey != null) {
runClient(new String[]{
"http://api.google.com/GoogleSearch.wsdl",
"doGoogleSearch", googleKey, "alek",
"0", "10", "false", "", "false", "",
"latin1", "latin1"});
} else {
System.err.println("Warning: pass your your google api
key as -D"+GOOGLE_KEY+"=XXXXXX");
}
//2005-01-17 error 200 OK body="" Content-Type: text/html
//runClient(new String[]{
// "http://www.ghettodriveby.com/soap/?wsdl",
"getRandomGoogleSearch", "aleksander slominksi"});
runClient(new String[]{
"http://www.xmethods.net/sd/2001/BabelFishService.wsdl", "BabelFish",
"en_fr", "I'm going to the beach."});
runClient(new String[]{
"http://www.webservicex.net/ValidateEmail.asmx?wsdl", "IsValidEMail",
"aleksander_at_example.com"});
runClient(new String[]{
"http://www.xmethods.net/sd/2001/TemperatureService.wsdl", "getTemp",
"02067"});
// java.io.IOException: Server returned HTTP response code:
502 for URL:
http://services.xmethods.net/soap/urn:xmethods-delayed-quotes.wsdl
// runClient(new String[]{
//
"http://services.xmethods.net/soap/urn:xmethods-delayed-quotes.wsdl",
// "getQuote", "IBM"});
runClient(new String[]{
"http://mssoapinterop.org/asmx/xsd/round4XSD.wsdl", "echoString", "Hello
World!!!"});
runClient(new String[]{
"http://samples.gotdotnet.com/quickstart/aspplus/samples/services/MathService/VB/MathService.asmx?WSDL",
"Add", "3", "4"});
runClient(new String[]{ //sometimes timeout
"http://www.webservicex.net/stockquote.asmx?WSDL", "GetQuote", "IBM"});
// runClient(new String[]{ //FAILING - cant find
WSDL
//
"http://developerdays.com/cgi-bin/tempconverter.exe/wsdl/ITempConverter",
"CtoF", "32"});
runClient(new String[]{
"http://www.webservicex.net/icd10.asmx?WSDL",
"GetICD10", "foo"});
//simple http://www.ghettodriveby.com/soap/?wsdl
//wsdl:import test
http://eutils.ncbi.nlm.nih.gov/entrez/eutils/soap/eutils.wsdl
runClient(new String[]{
"http://ws.netviagens.com/webservices/AirFares.asmx?wsdl", "GetFares",
"", "JFK", "WAW", "2005-01-20", "2005-02-02" });
} else {
runClient(args);
}
}
private static void runClient(String[] args) throws Exception {
//args[0] =
URI base = ((new File(".")).toURI());
if(args.length < 2) {
usage("at least two argument required");
}
String wsdlLoc = args[0];
//System.out.println("loaded def="+def);
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.out.println("invoking Google WS with query '"+query+"'
using WSDL from "+wsdlLoc);
System.err.println("invoking operation '"+opName+"' using WSDL
from "+wsdlLoc);
//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();
//WSDL URL = - ==> read from stdin
//allow arguments:
//1. [position=]value only allowed as first arguments if
position not specified (this is POSITIONAL!)
// position 1...
//2. name=value
//4. [name]=<xml>value
//
//-Depr=- ==> read from stdin
//-Dselect="XPATH filter"
//process arguments
// deal with stupid element= wrapping and other stuff (special
case for one part hat is element) ...
// for (int i = 2; i < args.length; i++) {
// //determine type of argument
// String partName = (String) partNames.next();
//partNames.get(i-2);
// String partValue = args[i];
// System.err.println(partName+"="+partValue);
// in.setObjectPart(partName, partValue);
// }
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)) {
String DEFAULT_STRING = "foo string";
in.setObjectPart(partName, DEFAULT_STRING);
System.err.println("defaulting
"+partName+"="+in.getObjectPart(partName));
} else if("anyURI".equals(localPart)) {
String DEFAULT_URI = "gsiftp://rainier//tmp/foo.txt";
in.setObjectPart(partName, DEFAULT_URI);
System.err.println("defaulting
"+partName+"="+in.getObjectPart(partName));
} else if("URIArrayType".equals(localPart)) {
XmlElement arrayEl = builder.newFragment(partName);
String DEFAULT_URI_ARRAY_ITEM =
"gsiftp://rainier//tmp/foo.txt";
arrayEl.addElement("value").addChild(DEFAULT_URI_ARRAY_ITEM);
in.setObjectPart(partName, arrayEl);
System.err.println("defaulting
"+partName+"="+in.getObjectPart(partName));
}
}
++count;
}
{
WSIFMessageElement inputMessage = ((WSIFMessageElement)in);
XmlNamespace ns = inputMessage.getNamespace(); // it is
qualified - children element must have namespace
inputMessage.addElement(ns, "item").addChild("keyboard");
}
// in.setObjectPart("key", key);
// in.setObjectPart("q", query);
// in.setObjectPart("start", "0");
// in.setObjectPart("maxResults", "10");
// in.setObjectPart("filter", "true");
// //restrict xsi:type="xsd:string"
// in.setObjectPart("safeSearch", "false");
// //lr xsi:type="xsd:string"
// in.setObjectPart("ie", "latin1");
// in.setObjectPart("oe","latin1");
if(op.isRequestResponseOperation()) {
WSIFMessage out = op.createOutputMessage();
WSIFMessage fault = op.createFaultMessage();
boolean succes = op.executeRequestResponseOperation(in, out,
fault);
if(succes) {
System.err.println("received response "+out);
} else {
System.err.println("received fault "+fault);
}
} else {
op.executeInputOnlyOperation(in);
System.out.println("input only message was sent successfully");
}
}
private static void addListOfElementNames(XmlElement sequenceEl,
List partNames) {
for(Iterator ei =
sequenceEl.requiredElementContent().iterator(); ei.hasNext(); ) {
XmlElement xsdSomething = (XmlElement) ei.next();
if(! xsdSomething.getName().equals("element")) {
throw new WSIFException("only xsd:element is supported
in xsd:sequence");
}
String name = xsdSomething.getAttributeValue(null, "name");
logger.fine("adding sequence element name="+name);
partNames.add(name);
}
}
}
/*
* Indiana University Extreme! Lab Software License, Version 1.2
*
* Copyright (c) 2002-2005 The Trustees of Indiana University.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* 1) All redistributions of source code must retain the above
* copyright notice, the list of authors in the original source
* code, this list of conditions and the disclaimer listed in this
* license;
*
* 2) All redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the disclaimer
* listed in this license in the documentation and/or other
* materials provided with the distribution;
*
* 3) Any documentation included with all redistributions must include
* the following acknowledgement:
*
* "This product includes software developed by the Indiana
* University Extreme! Lab. For further information please visit
* http://www.extreme.indiana.edu/"
*
* Alternatively, this acknowledgment may appear in the software
* itself, and wherever such third-party acknowledgments normally
* appear.
*
* 4) The name "Indiana University" or "Indiana University
* Extreme! Lab" shall not be used to endorse or promote
* products derived from this software without prior written
* permission from Indiana University. For written permission,
* please contact http://www.extreme.indiana.edu/.
*
* 5) Products derived from this software may not use "Indiana
* University" name nor may "Indiana University" appear in their name,
* without prior written permission of the Indiana University.
*
* Indiana University provides no reassurances that the source code
* provided does not infringe the patent or any other intellectual
* property rights of any other entity. Indiana University disclaims any
* liability to any recipient for claims brought by any other entity
* based on infringement of intellectual property rights or otherwise.
*
* LICENSEE UNDERSTANDS THAT SOFTWARE IS PROVIDED "AS IS" FOR WHICH
* NO WARRANTIES AS TO CAPABILITIES OR ACCURACY ARE MADE. INDIANA
* UNIVERSITY GIVES NO WARRANTIES AND MAKES NO REPRESENTATION THAT
* SOFTWARE IS FREE OF INFRINGEMENT OF THIRD PARTY PATENT, COPYRIGHT, OR
* OTHER PROPRIETARY RIGHTS. INDIANA UNIVERSITY MAKES NO WARRANTIES THAT
* SOFTWARE IS FREE FROM "BUGS", "VIRUSES", "TROJAN HORSES", "TRAP
* DOORS", "WORMS", OR OTHER HARMFUL CODE. LICENSEE ASSUMES THE ENTIRE
* RISK AS TO THE PERFORMANCE OF SOFTWARE AND/OR ASSOCIATED MATERIALS,
* AND TO THE PERFORMANCE AND VALIDITY OF INFORMATION GENERATED USING
* SOFTWARE.
*/
java -Dlog xsul.dii.XsulDynamicInvoker "!MISC/andre/GetPrice.wsdl"
getPrice keyboard
MLogger $Revision: 1.8 $ $Date: 2005/02/16 05:52:51 $ (GMT) configured
as '' (XSUL version compile-time:2.7.9 runtime:2.7.9)
Starting xsul.dii.XsulDynamicInvoker
invoking operation 'getPrice' using WSDL from !MISC/andre/GetPrice.wsdl
[ 18:52:58.769 main: xsul.wsif.impl.WSIFMessageElement.java:88
addPlaceholderForParameters 5]
elementPartQName={http://tempuri.org/}getPrice
[ 18:52:58.920 main: xsul.wsif.impl.WSIFMessageElement.java:184
addPlaceholderForParameters 5] special messageIn=<n1:getPrice
xmlns:n1="http://tempuri.org/" />
[ 18:52:58.920 main: xsul.wsif.impl.WSIFMessageElement.java:195
addPlaceholderForParameters 5] messageIn=<n1:getPrice
xmlns:n1="http://tempuri.org/" />
[ 18:52:58.940 main: xsul.wsif.impl.WSIFMessageElement.java:88
addPlaceholderForParameters 5]
elementPartQName={http://tempuri.org/}getPriceResult
[ 18:52:58.940 main: xsul.wsif.impl.WSIFMessageElement.java:245
addListOfElementNames 3] adding sequence element type
name=getPriceResult typeQName={http://www.w3.org/2001/XMLSchema}double
[ 18:52:58.940 main: xsul.wsif.impl.WSIFMessageElement.java:252
addListOfElementNames 3] adding sequence element name=getPriceResult
[ 18:52:58.940 main: xsul.wsif.impl.WSIFMessageElement.java:177
addPlaceholderForParameters 1] name=getPriceResult
[ 18:52:58.940 main: xsul.wsif.impl.WSIFMessageElement.java:184
addPlaceholderForParameters 5] special messageIn=<n1:getPriceResult
xmlns:n1="http://tempuri.org/"><n1:getPriceResult /></n1:getPriceResult>
[ 18:52:58.950 main: xsul.wsif.impl.WSIFMessageElement.java:195
addPlaceholderForParameters 5] messageIn=<n1:getPriceResult
xmlns:n1="http://tempuri.org/"><n1:getPriceResult /></n1:getPriceResult>
[ 18:52:58.960 main:
xsul.invoker.http.HttpDynamicInfosetInvoker.java:248 invokeXml 1]
host=localhost port=80 secure=false
[ 18:52:58.960 main:
xsul.http_client.plain_impl.PlainClientSocketFactory.java:45 connect 1]
connect localhost:80 timeout:240000
[ 18:52:59.250 main: trace.xsul.http.client.out
xsul.http_client.HttpClientRequest.java:244 writeHeaders 1] TRACE:
sending request headers:---
POST /GetPrice/Service.asmx HTTP/1.0\r
Host: localhost\r
User-Agent: XSUL/2.7.9\r
Content-Type: text/xml; charset=utf-8\r
Content-Length: 563\r
Keep-Alive: 300\r
SOAPAction: \"http://tempuri.org/getPrice\"\r
Connection: keep-alive\r
\r
---
[ 18:52:59.280 main: trace.xsul.http.client.out
xsul.http_client.HttpClientRequest.java:284 closeRequest 1] TRACE:
sending request body:---
<?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:getPrice
xmlns:n1='http://tempuri.org/'><n1:item>keyboard</n1:item></n1:getPrice></S:Body></S:Envelope>---
>
> 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
> <http://schemas.xmlsoap.org/ws/2002/12/policy>'
> xmlns:S='http://schemas.xmlsoap.org/soap/envelope/'
> <http://schemas.xmlsoap.org/soap/envelope/%27>>
> <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");
> }
> }
> }
>
--
The best way to predict the future is to invent it - Alan Kay
--------------090709020307080701020109
Content-Type: text/xml;
name="GetPrice.wsdl"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="GetPrice.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="getPrice">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="itme" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="getPriceResult">
<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:getPrice" />
</wsdl:message>
<wsdl:message name="getPriceSoapOut">
<wsdl:part name="parameters" element="tns:getPriceResult" />
</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:3333/GetPrice/Service.asmx" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
--------------090709020307080701020109--