|
|
Subject: Re: How to specify endpoint for web service request without pulling down entire WSDL? - msg#00042
Duncan Thomson wrote:
Lukas Jungmann wrote:
Duncan Thomson wrote:
Web services programming question:
The short version:
-----------------
In a client, how do I override at run-time, the <soap:address> that
was used when my stubs were built?
Get an instance of port and:
((BindingProvider)
port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
" http://some.address.com/service?wsdl");
Thanks, but I notice you're still giving a "?wsdl" reference there.
"?wsdl" part should not be required there, it is just an address of the
service, the JAX-WS runtime will take care of sending message to correct
<soap:address>
I don't want to specify the location of the WSDL, I want to use the
WSDL I already have, but just actually send my SOAP message to a
different server. In other words, I want to override the
<soap:address> that was specified in the WSDL I used when I build the
stubs. Does the above code do that?
No, there's JSR-110 for this stuff ( http://jcp.org/en/jsr/detail?id=110)
- reference implementation is wsdl4j
( http://sourceforge.net/projects/wsdl4j/).
Check also
http://java.sun.com/developer/community/askxprt/2007/jl0226.html -
mainly the part between Noel O'Connor and Jitendra Kotamraju
HTH,
--lj
After some groping around, I found that I can override the location
of the server by manually editing the catalog.xml file, then doing a
"refresh client". (Manually editing the wsdl file under
xml-resources/web-service-references/.../.../MyStuffService.wsdl
does not work.) It would be nice to have a feature to allow the
user to override the service location - I'll put in a feature request,
This is planned for NB 6.0 and definitely will be there.
OK, then I won't bother creating an IssueZilla request.
but anyway, I don't want to have to rebuild my client to do this!
Changes will have no effect if you don't rebuild the client...
Sorry, perhaps I didn't make myself clear. I meant I don't want to
have to rebuild the client when the server location changes - I want
to get the server location in the client at runtime. For example, I
might simply pass this into the client as a command line argument when
I start it up.
Thanks,
Duncan
Thread at a glance:
Previous Message by Date:
Re: How to specify endpoint for web service request without pulling down entire WSDL?
Lukas Jungmann wrote:
Duncan Thomson wrote:
Web services programming question:
The short version:
-----------------
In a client, how do I override at run-time, the <soap:address> that
was used when my stubs were built?
Get an instance of port and:
((BindingProvider)
port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
"http://some.address.com/service?wsdl");
Thanks, but I notice you're still giving a "?wsdl" reference there. I don't
want to specify the location of the WSDL, I want to use the WSDL I already have,
but just actually send my SOAP message to a different server. In other words, I
want to override the <soap:address> that was specified in the WSDL I used when I
build the stubs. Does the above code do that?
After some groping around, I found that I can override the location of
the server by manually editing the catalog.xml file, then doing a
"refresh client". (Manually editing the wsdl file under
xml-resources/web-service-references/.../.../MyStuffService.wsdl does
not work.) It would be nice to have a feature to allow the user to
override the service location - I'll put in a feature request,
This is planned for NB 6.0 and definitely will be there.
OK, then I won't bother creating an IssueZilla request.
but anyway, I don't want to have to rebuild my client to do this!
Changes will have no effect if you don't rebuild the client...
Sorry, perhaps I didn't make myself clear. I meant I don't want to have to
rebuild the client when the server location changes - I want to get the server
location in the client at runtime. For example, I might simply pass this into
the client as a command line argument when I start it up.
Thanks,
Duncan
Next Message by Date:
How do i retrieve soap message
Hi everyone.
I've generated a web service in netbeans 5.5 with SAAJ.
I've run my web service client. The incoming message (service soap response) is
empty.
The problem is, my soap message (payload) is not appearing in the soap response.
I expect this....
<?xml version="1.0" ?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://mywork">
<soapenv:Body>
<ns1:getMessageResponse>
<document>transfer<document>
<number>123456<number>
<telephone>555-12345<telephone>
</ns1:getMessageResponse>
</soapenv:Body>
</soapenv:Envelope>
But i receive this...
.....
<ns1:getMessageResponse>
<return/>
</ns1:getMessageResponse>
.....
My service and client method is listed below.
Service....
public SOAPMessage getMessage() {
SOAPMessage message = null;
try {
MessageFactory mf = MessageFactory.newInstance();
message = mf.createMessage();
SOAPPart sp = message.getSOAPPart();
SOAPEnvelope env = sp.getEnvelope();
SOAPBody body = env.getBody();
SOAPHeader header = env.getHeader();
header.detachNode();
SOAPFactory sf = SOAPFactory.newInstance();
Name ElName = sf.createName("getMessage", "ns1", "http:mywork");
SOAPBodyElement sbe = body.addBodyElement(ElName);
SOAPElement name = sbe.addChildElement("name");
name.addTextNode("transfer");
SOAPElement document = sbe.addChildElement("document");
document.addTextNode("123456");
SOAPElement telephone = sbe.addChildElement("telephone");
telephone.addTextNode("555-12345");
message.saveChanges();
} catch (Exception e) {
System.out.println(e.getMessage());
}
return message;
}
Client Request....
public static void main(String[] args) {
// TODO code application logic here
try {
SOAPConnectionFactory scf = SOAPConnectionFactory.newInstance();
SOAPConnection con = scf.createConnection();
MessageFactory mf = MessageFactory.newInstance();
message = mf.createMessage();
SOAPPart sp = message.getSOAPPart();
SOAPEnvelope env = sp.getEnvelope();
SOAPBody body = env.getBody();
SOAPHeader header = envelope.getHeader();
header.detachNode();
SOAPFactory sf = SOAPFactory.newInstance();
Name ElName = sf.createName("getMessage", "ns1", "http:mywork");
SOAPBodyElement sbe = body.addBodyElement(ElName);
message.saveChanges();
URL urlep = new URL("http://localhost:8080/jaxws05/jaxws05?WSDL");
SOAPMessage reply = con.call(message, urlep);
con.close();
} catch(Exception ex) {
// TODO handle custom exceptions here
}
}
Can anyone please help? , Thanks. --Nelson
Previous Message by Thread:
Re: How to specify endpoint for web service request without pulling down entire WSDL?
Lukas Jungmann wrote:
Duncan Thomson wrote:
Web services programming question:
The short version:
-----------------
In a client, how do I override at run-time, the <soap:address> that
was used when my stubs were built?
Get an instance of port and:
((BindingProvider)
port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
"http://some.address.com/service?wsdl");
Thanks, but I notice you're still giving a "?wsdl" reference there. I don't
want to specify the location of the WSDL, I want to use the WSDL I already have,
but just actually send my SOAP message to a different server. In other words, I
want to override the <soap:address> that was specified in the WSDL I used when I
build the stubs. Does the above code do that?
After some groping around, I found that I can override the location of
the server by manually editing the catalog.xml file, then doing a
"refresh client". (Manually editing the wsdl file under
xml-resources/web-service-references/.../.../MyStuffService.wsdl does
not work.) It would be nice to have a feature to allow the user to
override the service location - I'll put in a feature request,
This is planned for NB 6.0 and definitely will be there.
OK, then I won't bother creating an IssueZilla request.
but anyway, I don't want to have to rebuild my client to do this!
Changes will have no effect if you don't rebuild the client...
Sorry, perhaps I didn't make myself clear. I meant I don't want to have to
rebuild the client when the server location changes - I want to get the server
location in the client at runtime. For example, I might simply pass this into
the client as a command line argument when I start it up.
Thanks,
Duncan
Next Message by Thread:
Re: How to specify endpoint for web service request without pulling down entire WSDL?
Lukas Jungmann wrote:
Duncan Thomson wrote:
Lukas Jungmann wrote:
Duncan Thomson wrote:
Web services programming question:
In a client, how do I override at run-time, the <soap:address> that
was used when my stubs were built?
Get an instance of port and:
((BindingProvider)
port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
"http://some.address.com/service?wsdl");
I don't want to specify the location of the WSDL, I want to use the
WSDL I already have, but just actually send my SOAP message to a
different server. In other words, I want to override the
<soap:address> that was specified in the WSDL I used when I build the
stubs. Does the above code do that?
No, there's JSR-110 for this stuff...
OK, I really appreciate the help, but that answer was really confusing. I
checked out the links to JSR-110 - it's about manipulating the WSDL. I don't
think that's at all what I want to do...
I think you've already given me the solution, I just want to make sure:
Whatever value I set for ENDPOINT_ADDRESS_PROPERTY, using the code fragment you
provided above, overrides the value of <soap:address> in the WSDL that I used
when I generated the stubs. The WSDL is NOT downloaded at run-time.
Is that correct?
I'm curious. That code looks like the JAX-WS designers never intended it to be
used that way, otherwise they would have provided something simple like:
port.setEndPoint (serviceEndpoint);
Is there some rationale behind this?
Thanks.
|
|