Bonjour
je travaille sur un web service. à l'origine, j'avais un WSDL. j'ai donc utilisé wsconsume pour générer les POJO relatifs à mon web service.
j'ai crée mon implémentation de l'interface :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| @Stateless
@WebService(name = "WSPortName", targetNamespace = "http://mondomaine.fr")
@WebContext(contextRoot="/services/ws", urlPattern="/ServicesImpl/*")
public class WSImplService implements WSPortName {
@Resource
private WebServiceContext ctx;
@Override
@WebMethod(operationName = "Notify", action = "Notify")
@Oneway
public void notify(@WebParam(name = "Notification", partName = "Notification") RequestStructure notification)
{
}
...
} |
Mon code client est alors le suivant :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| public class WebServiceClient {
/**
* @param args
*/
public static void main(String[] args) {
WSPortName port = getServeurInterface();
...
port.notify(notification);
}
private static WSPortName getServeurInterface() {
URL urlCons = null;
try {
URL baseUrl = mondomaine.fr.WSPortName.class.getResource(".");
urlCons = new URL(baseUrl, "http://localhost:8080/services/ws/MesServices");
}
catch (MalformedURLException e) {
}
WSPortNameServices service = new WSPortNameServices(urlCons, new QName("http://mondomaine.fr", "WSImplServiceService"));
WSPortName cons = service.getPort(new QName("http://mondomaine.fr", "WSPortNamePort"), WSPortName.class);
return cons;
}
} |
Ça fonctionne très bien comme cela.
La subtilité, c'est que dans l'URL qu'est censé me fournir le client, je dois rajouter une information.
L'URL coté client devient alors :
http://localhost:8080/services/ws/MesServices?data=TOTO
Mais là, j'ai une erreur :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| Exception in thread "main" javax.xml.ws.WebServiceException: Failed to access the WSDL at: http://localhost:8080/services/ws/MesServices?data=TOTO. It failed with:
Server returned HTTP response code: 405 for URL: http://localhost:8080/services/ws/MesServices?data=TOTO.
at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(RuntimeWSDLParser.java:162)
at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:144)
at com.sun.xml.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:265)
at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:228)
at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:176)
at com.sun.xml.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:104)
at javax.xml.ws.Service.<init>(Service.java:56)
at uk.org.siri.wsdl.SiriDeliveryServices.<init>(SiriDeliveryServices.java:42)
at WebServiceClient.getServeurInterface(WebServiceClient.java:63)
at WebServiceClient.main(WebServiceClient.java:34)
Caused by: java.io.IOException: Server returned HTTP response code: 405 for URL: http://localhost:8080/services/ws/MesServices?data=TOTO
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1436)
at java.net.URL.openStream(URL.java:1010)
at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.createReader(RuntimeWSDLParser.java:804)
at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.resolveWSDL(RuntimeWSDLParser.java:262)
at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:129)
... 8 more |
J'ai essayé une URL du genre :
http://localhost:8080/services/ws/MesServices/data=TOTO
Dans ce cas, je n'ai pas d'erreur, mais, dans le WebContext je n'arrive pas à retrouver la partie qui m'intéresse data=TOTO.
Bref, est-il possible de récupérer d'une façon ou d'une autre soit la query string (?data=TOTO) ou bien la dernière partie de mon URL (/data=TOTO) ?
Nota : je ne peux pas modifier le WSDL...
Auriez-vous une idée SVP ?
Cordialement
Partager