Loading ...
Sorry, an error occurred while loading the content.

Java client for .NET-webservice

Expand Messages
  • sb_sandrabauer
    Hello, I ve written a Java client(Apache SOAP) with JBuilder, which should communicate with my webservice written un C#. The client sends a string, which he
    Message 1 of 2 , Dec 6, 2001
    • 0 Attachment
      Hello,

      I've written a Java client(Apache SOAP) with JBuilder,
      which should communicate with my webservice written un C#.
      The client sends a string, which he gets over a GUI, to
      the webservice. The webservice sends back the
      message: "Hello"+string.

      I call the webservice with:
      resp = call.invoke
      (url , "http://localhost/EchoService/Echo");

      (My namespace is called "Webservice", my Service ich
      called "EchoService" and the method is called "Echo".)

      I call for the response like this:
      try {
      System.out.println(url);
      resp = call.invoke(url , "http://localhost/EchoService/Echo");
      }
      catch(SOAPException ex) {
      System.err.println("Caught SOAPException (" + ex.getFaultCode()
      + "):" + ex.getMessage());
      System.exit(-1);
      }

      if (resp != null) {
      ret = resp.getReturnValue();
      System.out.println("resp object is: " + resp);
      Object value = ret.getValue();
      System.out.println("value object is: " + value);
      try {
      System.out.println("getPartCount returns: " +
      resp.getPartCount());
      }
      catch(javax.mail.MessagingException e){
      System.out.println("Exception caught: " + e);
      }
      }
      else {
      Fault fault = resp.getFault();
      System.err.println("Generated fault: ");
      System.err.println(" Fault Code = " + fault.getFaultCode());
      System.err.println(" Fault String = " + fault.getFaultString());
      }

      String serviceResponse = value.toString();
      return serviceResponse;
      }
      }

      Now I get the following response:
      Invoke this call: [Header=null] [methodName=Echo]
      [targetObjectURI=http://localhost/EchoService/Echo%5d
      [encodingStyleURI=http://schemas.xmlsoap.org/soap/encoding/%5d
      [SOAPContext=[Parts={}]] [Params={[[name=txt] [type=class
      java.lang.String] [value="String,which I enter"]
      [encodingStyleURI=http://schemas.xmlsoap.org/soap/encoding/%5d]}]
      resp object is: [Header=null] [methodName=null]
      [targetObjectURI=null] [encodingStyleURI=null] [SOAPContext=[Parts=
      {[cid:null type: text/xml; charset=utf-8 enc: null]}]] [fault=
      [Attributes={}] [faultCode=soap:Client]
      [faultString=System.Web.Services.Protocols.SoapException: Server did
      not recognize the value of HTTP Header SOAPAction:
      http://localhost/EchoService/Echo.
      at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
      at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type
      type, HttpContext context, HttpRequest request, HttpResponse
      response)] [faultActorURI=null] [DetailEntries=
      ] [FaultEntries=]] [Params={}]
      Exception occurred during event dispatching:
      java.lang.NullPointerException
      at hellowebservice.TestClient.callService(TestClient.java:85)
      at hellowebservice.UserInterface.jButton1_actionPerformed
      (UserInterface.java:87)
      at hellowebservice.UserInterface$1.actionPerformed
      (UserInterface.java:59)
      at javax.swing.AbstractButton.fireActionPerformed
      (AbstractButton.java:1450)
      at
      javax.swing.AbstractButton$ForwardActionEvents.actionPerformed
      (AbstractButton.java:1504)
      at javax.swing.DefaultButtonModel.fireActionPerformed
      (DefaultButtonModel.java:378)
      at javax.swing.DefaultButtonModel.setPressed
      (DefaultButtonModel.java:250)
      at javax.swing.plaf.basic.BasicButtonListener.mouseReleased
      (BasicButtonListener.java:216)
      at java.awt.Component.processMouseEvent(Component.java:3717)
      at java.awt.Component.processEvent(Component.java:3546)
      at java.awt.Container.processEvent(Container.java:1167)
      at java.awt.Component.dispatchEventImpl(Component.java:2595)
      at java.awt.Container.dispatchEventImpl(Container.java:1216)
      at java.awt.Component.dispatchEvent(Component.java:2499)
      at java.awt.LightweightDispatcher.retargetMouseEvent
      (Container.java:2458)
      at java.awt.LightweightDispatcher.processMouseEvent
      (Container.java:2223)
      at java.awt.LightweightDispatcher.dispatchEvent
      (Container.java:2132)
      at java.awt.Container.dispatchEventImpl(Container.java:1203)
      at java.awt.Window.dispatchEventImpl(Window.java:918)
      at java.awt.Component.dispatchEvent(Component.java:2499)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:336)
      at java.awt.EventDispatchThread.pumpOneEventForHierarchy
      (EventDispatchThread.java:134)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy
      (EventDispatchThread.java:101)
      at java.awt.EventDispatchThread.pumpEvents
      (EventDispatchThread.java:96)
      at java.awt.EventDispatchThread.run
      (EventDispatchThread.java:88)

      So I think, my Webservice don't undrestad the request. But why?
      Here's my webservice:
      namespace SandraWebservice
      {
      [WebService(Namespace="http://localhost/EchoService/")]
      public class EchoService : System.Web.Services.WebService
      [WebMethod(Description="Enter a name and this Webservice
      returns 'Hello' with this name")]
      [System.Web.Services.Protocols.SoapRpcMethodAttribute
      ("http://localhost/Echoservice/Echo",
      RequestNamespace="http://localhost/Echoservice/",
      ResponseNamespace="http://localhost/Echoservice/")]
      public string Echo(string txt) {
      return "Hello " + txt;
      }}
    • james chen
      hi all: I was having a discussing about web service and SOAP with a bunch of people and one question rise in the end. Where is web service going?? The idea of
      Message 2 of 2 , Dec 6, 2001
      • 0 Attachment
        hi all:

        I was having a discussing about web service and SOAP
        with a bunch of people and one question rise in the
        end.

        Where is web service going??


        The idea of web service sounds like "individual
        method" reuse, with the only exception it is on the
        web. If we look in the pass, history has proven that
        the chances of reusing an individual method are really
        low and most likely by the person who creates it
        only”.

        Even with all participating player such MS, SUN and
        IBM start to make their product base on SOAP for
        various reasons. The trouble is that they are building
        proprietary systems on top of SOAP, so one wonders if
        they will be interoperable in practice. For
        example, http is at the heart of web interaction, but
        developers still have to make separate considerations
        for Explorer and Netscape.


        Even all the venders make their API and xml interop,
        the question still remains who would be using those
        services. Even through the S/W vender can make their
        product base on web service / SOAP but it raises
        another concern, those functions would be very
        particular eg. Creating a spreadsheet.
        .


        Can all of you web service/ soap experts enlighten us
        ?


        Thanks
        james c


        -----------------------------------------------------------------
        < 每天都 Yahoo!奇摩 > www.yahoo.com.tw
      Your message has been successfully submitted and would be delivered to recipients shortly.