1

I have simple web service :

I have the same problem. when I don't append "?wsdl" I have soap faylt. how can I avoid this exception?

@WebService
@SOAPBinding(style = Style.RPC)
public interface TimeServer {
    @WebMethod
    @WebResult(partName = "time_response")
    String getTimeAsString();

    @WebMethod
    @WebResult(partName = "time_response")
    long getTimeAsElapsed();

}

and impl:

@WebService(endpointInterface = "x.y.z.TimeServer")
public class TimeServiceImpl implements TimeServer {


    public TimeServiceImpl() {}

    @Override
    public String getTimeAsString() {return new Date().toString();}

    @Override
    public long getTimeAsElapsed() {return new Date().getTime();}

}

I run this web service in Jboss As 7.0.1. Everything works well!

When I open link localhost:8080/project/time?wsdl everything works well - I have wsdl.

but when I don't append "?wsdl" I have exception.

14:26:58,192 WARNING [org.apache.cxf.phase.PhaseInterceptorChain] (http-localhost-127.0.0.1-8080-1) Interceptor for {http://x.z.y/}HelloWorld has thrown exception, unwinding now: org.apache.cxf.interceptor.Fault: No such operation: null (HTTP GET PATH_INFO: /project/timenull)
at org.apache.cxf.interceptor.URIMappingInterceptor.handleMessage(URIMappingInterceptor.java:88)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)

and I have this response from server:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>
     No such operation: null (HTTP GET PATH_INFO: /soap-service/timenull)
</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>

how can I avoid this exception?

It will be better , if client will see another message, instead of this error response? how can I send another XML when client opens link without "?wsdl"?

thnaks

grep
  • 5,465
  • 12
  • 60
  • 112

2 Answers2

2

Webservices won't support HTTP GET. If you enter the service url its directly making a HTTP GET. Thats the reason it responds with the error No such operation

Instead you need to make a SOAP POST to get response from webservice. Write a webservice client for this. You can refer this link for creating webservice clients

Dinal
  • 661
  • 4
  • 9
  • As you sad, there is no way to avoid this exception? or can't I redirect to wsdl? or cant I send another error response? I know how to write web service client. I have already done this. I have another question. I want to avoid or disable this exception. – grep Jun 26 '14 at 11:22
  • You are getting this error while hitting the service url in browser, correct? This means your request is not even entering the service. So theres no way to throw an exception. You can try out Urlrewrite if you want to redirect to ?wsdl url. – Dinal Jun 26 '14 at 11:45
  • Yes I get this error while I open the link using in browser. what do you mean when you tell me " You can try out Urlrewrite"? – grep Jun 26 '14 at 11:58
  • 1
    Check this link : http://tuckey.org/urlrewrite/ . You can also try out apache mod_rewrite : http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html – Dinal Jun 26 '14 at 12:05
0

@grep I see this post as bit old, but still will try to answer if anyone else with similar problem is able to. Well, I had the same issue and wondered what were the reasons behind those. here are the two steps that i tried and fixed up the issue. make sure you are able to access the wsdl in browser.

  1. Close the SOAPUI, delete the soapui_workspace.xml created in user folder under C:/users.
  2. Restart the Soap_ui and open up preferences>Proxy setting.
  3. Change from automatic to None.
  4. Create new project. This did solved my issue and got the response from webservice in SOAPUI.

    Secondly, in this case, make sure you have deployed the webservice correctly as mentioned by @Dinal.

Aman Verma
  • 46
  • 2