Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: couldnt call one webservice from other webservice getting not an interface error and IllegalArgumentException at runtime

  1. #1
    Junior Member
    Join Date
    Aug 2014
    Posts
    7
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default couldnt call one webservice from other webservice getting not an interface error and IllegalArgumentException at runtime

    Task :
    I have to a develop client which access a webservice (which in turn will communicate with another dummy webservice) to give back the response to the client.

    What I have developed so far :

    I have developed a client and two webservices.

    My Code :

    dummy webservice
    - a webservice which will give a hard coded response

    package groups.yashey;
     
    import javax.jws.WebService;
    import javax.jws.WebMethod;
    import javax.xml.soap.SOAPMessage;
     
    @WebService
    public interface SendFaxResponseInterface {
     
      @WebMethod
      public void sendFaxResponse();
    }
     
    package groups.yashey;
     
     
    import javax.jws.WebService;
    import javax.jws.WebMethod;
    import java.io.FileOutputStream;
    import javax.xml.soap.MessageFactory;
    import javax.xml.soap.SOAPHeaderElement;
    import javax.xml.soap.SOAPBody;
    import javax.xml.soap.SOAPBodyElement;
    import javax.xml.soap.SOAPEnvelope;
    import javax.xml.soap.SOAPHeader;
    import javax.xml.soap.SOAPMessage;
    import javax.xml.soap.SOAPPart;
     
     
    @WebService
    public class SendFaxResponseWebService implements SendFaxResponseInterface {
      @WebMethod
      public void sendFaxResponse() {
      MessageFactory factory = null;
      SOAPMessage soapMsg = null;
      SOAPPart part = null;
      SOAPEnvelope envelope = null;
      SOAPHeader header = null;
      SOAPBody body = null;
      SOAPHeaderElement headerElement = null;
      SOAPBodyElement element = null;
      SOAPBodyElement soapElement1 = null;
      SOAPBodyElement soapElement2 = null;
      SOAPBodyElement soapChildElementOfSoapElement2 = null;
      SOAPBodyElement soapSecondChildElementOfSoapElement2  = null;
      UserDetailsBean userBeanObj = new UserDetailsBean();
      userBeanObj.setUsername("admin");
      userBeanObj.setPassword("admin");
     
     
      if(  userBeanObj.getUsername().equals("admin") && userBeanObj.getPassword().equals("admin") ) {
      try{
      factory = MessageFactory.newInstance();
      soapMsg = factory.createMessage();
      part = soapMsg.getSOAPPart();
      envelope = part.getEnvelope();
      header = envelope.getHeader();
      body = envelope.getBody();
     
     
      headerElement = header.addHeaderElement(envelope.createName("Response","","http://ws.easylink.com/RequestResponse/2011/01"));
      headerElement.addChildElement("SenderKey").addTextNode("http://xoa.xpedite.com/JobSubmit");
      headerElement.addChildElement("RequestID").addTextNode("BNP_TEST_JOB14");
      headerElement.addChildElement("ProcessingID").addTextNode("0ACD321E-1163-130724184717275");
     
     
      element = body.addBodyElement(envelope.createName("jobSubmitResult","","http://ws.easylink.com/JobSubmit/2011/01"));
     
     
      soapElement1 = (SOAPBodyElement) element.addChildElement("Status");
      soapElement1.addChildElement("StatusCode").addTextNode("0");
      soapElement1.addChildElement("SubmissionTime").addTextNode("2013-07-24T18:47:17.275Z");
      soapElement1.addChildElement("CompletionTime").addTextNode("2013-07-24T18:47:18.180Z");
      element.addChildElement("SubmitId").addTextNode("BNPTest1");
     
     
     
     
      soapElement2 = (SOAPBodyElement) element.addChildElement("MessageResult");
      soapElement2.addChildElement("MessageId").addTextNode("BNP_TEST1_MSG14");
     
     
      soapChildElementOfSoapElement2 = (SOAPBodyElement) soapElement2.addChildElement("Status");
      soapChildElementOfSoapElement2.addChildElement("StatusCode").addTextNode("0");
      soapChildElementOfSoapElement2.addChildElement("StatusMessage").addTextNode("OK");
      soapChildElementOfSoapElement2.addChildElement("SubmissionTime").addTextNode("2013-07-24T18:47:17.338Z");
      soapChildElementOfSoapElement2.addChildElement("CompletionTime").addTextNode("2013-07-24T18:47:18.180Z");
     
     
      soapSecondChildElementOfSoapElement2 = (SOAPBodyElement) soapElement2.addChildElement("JobId");
      soapSecondChildElementOfSoapElement2.addChildElement("XDN").addTextNode("flusme");
      soapSecondChildElementOfSoapElement2.addChildElement("MRN").addTextNode("1130365");
     
     
      // writing the soap message to console
      //soapMsg.writeTo(System.out);
     
     
     
     
      // writing the soap message to file
      soapMsg.writeTo(new FileOutputStream("NewSoapMessage.xml"));
      System.out.println("Soap message written to the file");
     
     
      }catch(Exception e){
        e.printStackTrace();
           }
         }
      }
    }

    another Webservice
    - this is responsible to access the dummy webservice on the client request
    package groups.yashey;
     
    import javax.jws.WebService;
    import javax.jws.WebMethod;
     
    @WebService
    public interface SendFaxClientWSInterface {
     
      @WebMethod
      public void sendFax();
    }
     
    package groups.yashey;
     
    import javax.jws.WebService;
    import javax.jws.WebMethod;
     
    @WebService
    public class SendFaxClientWS implements SendFaxClientWSInterface {
     
      @WebMethod
      public void sendFax() {
      new SendFaxResponseWebServiceService(). getSendFaxResponseWebServicePort().sendFaxResponse();
      }
    }





    client
    - a stand alone program to call the webservice.
    import groups.yashey.*;
    public class SendFaxWebServiceClient {
      public static void main(String...ar) {
         new SendFaxClientWSService().getSendFaxClientWSPort().sendFax();
      }
    }

    extra helper classes

    - this class helps to get the data to the webservice

    package groups.yashey;
     
     
    public class UserDetailsBean {
      private String username;
      private String password;
     
      public UserDetailsBean() {
      System.out.println("UserDetailsBean Object is Created");
      }
     
      public String getUsername() {
      return username;
      }
     
      public void setUsername(String username) {
      this.username = username;
      }
     
      public String getPassword() {
      return password;
      }
     
      public void setPassword(String password) {
      this.password = password;
      }
    }

    - these classes are used to publish the webservices
    package groups.yashey;
    import groups.yashey.SendFaxResponseInterface;
    import groups.yashey.SendFaxResponseWebService;
    import groups.yashey.SendFaxClientWSInterface;
    import groups.yashey.SendFaxClientWS;
     
    import javax.xml.ws.Endpoint;
     
    public class PublishWebService1 {
      public static void main(String...ar) {
     
      SendFaxResponseInterface sendFaxWebService = new SendFaxResponseWebService();
      //SendFaxClientWSInterface sendFaxWebServiceClient = new SendFaxClientWS();
     
      Endpoint.publish("http://localhost:7770/sendFaxWebService", sendFaxWebService);
      //Endpoint.publish("http://localhost:7771/sendFaxWebServiceClient", sendFaxWebServiceClient);
     
      System.out.println("SendFax webservice is ready...");
      //System.out.println("SendFax webservice client is also ready...");
     
      }
    }
     
    package groups.yashey;
    import groups.yashey.SendFaxResponseInterface;
    import groups.yashey.SendFaxResponseWebService;
    import groups.yashey.SendFaxClientWSInterface;
    import groups.yashey.SendFaxClientWS;
     
    import javax.xml.ws.Endpoint;
     
     
    public class PublishWebService2 {
      public static void main(String...ar) {
     
      SendFaxClientWSInterface sendFaxWebServiceClient = new SendFaxClientWS();
      Endpoint.publish("http://localhost:7771/sendFaxWebServiceClient", sendFaxWebServiceClient);
     
      //System.out.println("SendFax webservice is ready...");
      System.out.println("SendFax webservice client is also ready...");
      }
    }
    Errors Iam getting :

    - both are run time errors
    - one is saying my service is not an interface
    - other one throwing IllegalArgumentException at my dummy web service

    C:\Users\Yaswanth\Desktop>java SendFaxWebServiceClient
    Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: groups.yashey.SendFaxResponseWebService is not an interface
            at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:178)
            at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:111)
            at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)
            at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)
            at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:107)
            at com.sun.proxy.$Proxy27.sendFax(Unknown Source)
            at SendFaxWebServiceClient.main(SendFaxWebServiceClient.java:9)
     
    C:\Users\Yaswanth\Desktop\MyOwn WebServices>java groups.yashey.PublishWebService2
    Sep 2, 2014 1:06:21 PM com.sun.xml.internal.ws.model.RuntimeModeler getRequestWrapperClass
    INFO: Dynamically creating request wrapper Class groups.yashey.jaxws.SendFax
    Sep 2, 2014 1:06:21 PM com.sun.xml.internal.ws.model.RuntimeModeler getResponseWrapperClass
    INFO: Dynamically creating response wrapper bean Class groups.yashey.jaxws.SendFaxResponse
    SendFax webservice client is also ready...
    Sep 2, 2014 1:08:08 PM com.sun.xml.internal.ws.model.RuntimeModeler getResponseWrapperClass
    INFO: Dynamically creating response wrapper bean Class groups.yashey.jaxws.SendFaxResponseResponse
    Sep 2, 2014 1:08:08 PM com.sun.xml.internal.ws.server.sei.EndpointMethodHandler invoke
    SEVERE: groups.yashey.SendFaxResponseWebService is not an interface
    java.lang.IllegalArgumentException: groups.yashey.SendFaxResponseWebService is not an interface
            at java.lang.reflect.Proxy.getProxyClass0(Proxy.java:470)
            at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:690)
            at com.sun.xml.internal.ws.client.WSServiceDelegate$4.run(WSServiceDelegate.java:629)
            at java.security.AccessController.doPrivileged(Native Method)
            at com.sun.xml.internal.ws.client.WSServiceDelegate.createProxy(WSServiceDelegate.java:625)
            at com.sun.xml.internal.ws.client.WSServiceDelegate.createEndpointIFBaseProxy(WSServiceDelegate.java:610)
            at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:311)
            at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:293)
            at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:275)
            at javax.xml.ws.Service.getPort(Service.java:92)
            at groups.yashey.SendFaxResponseWebServiceService.getSendFaxResponseWebServicePort(SendFaxResponseWebServiceService.java:56)
            at groups.yashey.CallSendFaxService.callSendFaxService(CallSendFaxService.java:5)
            at groups.yashey.SendFaxClientWS.sendFax(SendFaxClientWS.java:12)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at com.sun.xml.internal.ws.api.server.InstanceResolver$1.invoke(InstanceResolver.java:235)
            at com.sun.xml.internal.ws.server.InvokerTube$2.invoke(InvokerTube.java:135)
            at com.sun.xml.internal.ws.server.sei.EndpointMethodHandler.invoke(EndpointMethodHandler.java:246)
            at com.sun.xml.internal.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:82)
            at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Fiber.java:587)
            at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Fiber.java:546)
            at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Fiber.java:531)
            at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Fiber.java:428)
            at com.sun.xml.internal.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:232)
            at com.sun.xml.internal.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:460)
            at com.sun.xml.internal.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:233)
            at com.sun.xml.internal.ws.transport.http.server.WSHttpHandler.handleExchange(WSHttpHandler.java:95)
            at com.sun.xml.internal.ws.transport.http.server.WSHttpHandler.handle(WSHttpHandler.java:80)
            at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:65)
            at sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:65)
            at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:68)
            at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:557)
            at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:65)
            at sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:529)
            at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
            at java.lang.Thread.run(Thread.java:662)
    Last edited by yash_java; September 3rd, 2014 at 01:58 AM.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,166
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: couldnt call one webservice from other webservice getting not an interface error and IllegalArgumentException at runtime

    Please edit your post and wrap your code with code tags:
    [code=java]
    YOUR CODE GOES HERE
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  3. The Following User Says Thank You to Norm For This Useful Post:

    yash_java (September 3rd, 2014)

Similar Threads

  1. HTML call to a Webservice
    By kienkun1990 in forum Web Frameworks
    Replies: 2
    Last Post: January 5th, 2014, 01:57 AM
  2. Replies: 2
    Last Post: September 16th, 2013, 03:32 PM
  3. webservice
    By prabhat11 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 27th, 2013, 08:19 AM
  4. Replies: 0
    Last Post: September 21st, 2012, 11:11 AM
  5. How to call webservice in java?
    By Subhasri in forum Web Frameworks
    Replies: 2
    Last Post: September 30th, 2011, 09:15 AM

Tags for this Thread