Difference between ".wsdl"and "?wsdl" in wsdl Url - java

I have a jax-ws web service deployed on web sphere server and when I am trying to access the wsdl in browser with the url
"Http://localhost:7001/HelloWorldService/port/helloworld?wsdl"
I see that the url is getting changed to the below one
"Http://localhost:7001/HelloWorldService/port/helloworld/HelloWorldService.wsdl"
Can someone explain the difference between these both .wsdl and ?wsdl and what needs to be done to keep the url same as ?wsdl instead of getting changed to .wsdl?

helloworld?wsdl --> is just a request to the service provider so you can get the wsdl.
HelloWorldService.wsdl" --> This is the actual file that describes the service which has set of endpoints.

Related

Issue with rest end point in Weblogic server

I have created rest api with following url-pattern in web.xml file.
/service/*
Its working fine in tomcat server with URL http://localhost:9080/context/service/test
however, in the WebLogic server, its getting failed with the above URL. But when I am using the following URL, It's working fine.
http://localhost:9080/context/resources/test
I am not sure why given first given URL not working with the web-logic server.
Please suggest.
Thanks in Advance
In web logic by default context name is given as resources( you can check in WADL file in web logic console resource folder), however you may further overwrite if required.

adding security parameter to a webservice client in java that its implemented in E-BUSINESS with role-base approach

I want to implement web service client with the wsdl that its created with
E-BUSINESS suite.the authentication parameter are added to this wsdl with
role-base approuch or active-base because it does not have any tag with this name in SOAHEADER XML but for result it needs them.
how can i add username and password to web service in my java codes.
this is soaHeader xml...

WSDL without endpoint URL

Can a WSDL exist without an Endpoint defined in it? I received an WSDL from client which dont have have endpoint defined.
Just want to know what are the possibilities if it exist somewhere else or in some other relative location etc since I don't have expertise in SOAP services.
To make clear further the WSDL dont have soap:address neither service tag.
It sure can. The same WSDL can be defined for multiple endpoints. You need to ask the client which address(es) to use with that.
You can bind the end point at runtime dynamically even if it has not been defined in the WSDL. Below is the example of javax.xml.ws.BindingProvider. You can configure your end point in DB or configuration file thus it can be changed as per the environment.
((BindingProvider)port).getRequestContext().put(
BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endPoint);

Need to add SOAP security token

I need to set a custom soap header attribute on a jax-ws generated webservice client. I my case all webservice calls must go through a proxy server requiring a specific token (recieved from the web request header) to be present in the soap request header. E.g.:
1 CarServiceService service = null;
2 service = new CarServiceService(new URL(url), new QName(qname);
3 CarServiceEndpoint port = service.getCarServicePort();
It seems that in line 3 the wsdl is retrieved and my call fails due to the missing security token. Could any one point to direction on how this is done?
A detailed example has been mentioned here:
Creating and Deploying JAX-WS web service on Tomcat 6
This article shows how to create and use security token.
I was able to resolve my issue from this blog post: http://tugdualgrall.blogspot.dk/2009/02/jax-ws-how-to-configure-service-end_17.html
Basically I needed to set the webservice endpoint manually instead of the framework trying to extract the endpoint from the requested wsdl - which failed.

Using CXF With an WSDL that has unpublished metadata

I'm using CXF to to communicate with a WSDL made in WCF. The WCF side of things was created following a tutorial. The Java code has been generated using a Maven script.
I have gotten things working using HTTPS for encryption. I have gotten authentication working. However, I would like to have the WSDL metadata turned off on the WCF side and still be able to use the Java side to talk to the service.
Currently, I can access the service with metadata publishing on from the Java side using this code:
URL wsdlLocation = new URL("https://server.com:7010/Hservice?wsdl");
HttpsURLConnection connection = (HttpsURLConnection) wsdlLocation.openConnection();
HService service = new HService(wsdlLocation);
HAdminService calc = service.getHAdminService();
... (authentication using WSS4JOutInterceptor code and unrelated code here)
System.out.println(calc.add(new Double(5), new Double(5)));
However, when I turn off metadata publishing on the WCF side I get this error:
Exception in thread "main" javax.xml.ws.WebServiceException:
org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:149)
at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:90)
at javax.xml.ws.Service.<init>(Service.java:56)
at com.blah.hservice.v_1_0.HService.<init>(HService.java:49)
at Main.main(Main.java:85)`
The page the wsdl is on displays this with metadata publishing turned off (this is an excerpt):
This is a Windows© Communication Foundation service.
Metadata publishing for this service is currently disabled.
If you have access to the service, you can enable metadata publishing by completing the following steps to modify your web or application configuration file:
I expected to be able to search "CXF metadata unpublished" and see lots of people doing this...but have not found anything. How do I communicate with this service without the WSDL being published?
You really have two options:
Copy the wsdl locally and point the client at the local wsdl. This is likely the "best" option as it makes sure all the information in the wsdl (like policies and such) is used.
Use "null" for the wsdl location (note: not JAX-WS portable). You will need to call service.addPort(....) after creating the service and before calling getHAdminService to add the port with the appropriate binding and endpoint address. CXF can work most of the time without the WSDL (will internally generate what is needed from the annotations). However, if things like policies are defined in the WSDL, then it cannot.
I got this to work with Client code I generated using CXF 2.6.5
Make sure the QName(first argument) matches the QName the getHAdminService() method references. The bindingId(second argument) should be one of the constants defined in SOAPBinding Interface (javax.xml.ws.soap.SOAPBinding).

Categories