Hi,
You can modify the service endpoint in the WSDL definition programmatically. Here is some sample code which should do this (not compiled or tested, but it should be approximately correct). This uses the standard WSDL API being defined in JSR110 (see http://oss.software.ibm.com/developerworks/projects/wsdl4j for the reference implementation).
WSDLFactory factory = WSDLFactory.newInstance();
WSDLReader reader = factory.newWSDLReader();
Definition def = reader.readWSDL(null,"sample.wsdl");
Service service = def.getService(new QName("foo","bar"); // accesses service named foo:bar
List extElements = service.getExtensibilityElements();
SOAPAddress address = (SOAPAddress) extElements.get(0); // this assumes that there is only one extensibility element under <service>, viz. soap:address
address.setLocationURL("http://newURI");
Now the definition (def) can be used by WSIF to create a WSIFService that will attempt to invoke the service whose SOAP endpoint is http://newURI.
Hope that helps,
Nirmal.
"David Seager" <[EMAIL PROTECTED]>
10/30/2003 08:13 AM
|
To: [EMAIL PROTECTED] cc: Subject: Re: Service Name's soap:address location |
Hi Leo,
That WSDL shouldn't execute correctly from a remote client, as localhost
will resolve to the machine it's being run on. The best way is to store the
WSDL on a web server on the remote server machine, with the location set
with the remote server's hostname. Then point the client at the WSDL on the
remote server.
However, if you know which provider gets used, there are methods on some to
override the location URL. In the WSIFPort_ApacheAxis class, in the Apache
Axis provider, there is a setEndPoint method which will do the trick. Here
is my code which changes the URL to something else:
String wsdlLocation = "http://localhost:8080/axis/Expire.jws?wsdl";
WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
WSIFService service = factory.getService(wsdlLocation, null, null,
null, null);
WSIFPort p = service.getPort();
// override port
WSIFPort_ApacheAxis pA = (WSIFPort_ApacheAxis)p;
pA.setEndPoint(new URL("http://localhost:8081/axis/Expire.jws"));
o = p.createOperation(operation);
m1 = o.createInputMessage();
m2 = o.createOutputMessage();
m3 = o.createFaultMessage();
boolean ok = o.executeRequestResponseOperation(m1, m2, m3);
The WSDL referenced defines the Expire service to be at
http://localhost:8080/axis/Expire.jws. However, the above code sends the
request to the address in the override call. This only works if the
provider being used is Apache Axis.
Regards,
David Seager
IBM Hursley
Internet [EMAIL PROTECTED]
"Leo Barcenas"
<[EMAIL PROTECTED] To: <[EMAIL PROTECTED]>
> cc:
Subject: Service Name's soap:address location
30/10/2003 11:33
Please respond to
wsif-user
Hello!
I would like to ask about the WSDL file used in WSIF. In particular,
the soap:address location of the Service name.
I'm just quiet puzzled that some of the files I saw is written the one
below,
<service name="ServiceNM">
<port name="SoapPort" binding="tns:SoapBinding">
<soap:address location="http://localhost/WSDL/iLON100.WSDL" />
</port>
</service>
Considering the above WSDL syntax, will this be able to correctly execute
from a remote client? If not, is there a way that you can change
"localhost"
into the IP address of the server where the web service is located during
runtime? I've tried it in VB.NET by using the WebReference's URL property
and replacing "localhost" to the server's IP address.
Hoping for your answer.
Many thanks.
Leo