7 Replies Latest reply on Oct 26, 2006 6:47 PM by jason.greene

    Consuming .net Web Service using JBOSSWS

    vimalm

      Hi

      I am trying to consume a .net webservice (document/literal) inside one of my EJB's or a stand alone client starting from a WSDL URL in the form http://someurl/someservice.asmx

      The steps I took is to create the supporting classes using WSTOOLS with following configuration and then invoking the web service.


      <configuration xmlns="http://www.jboss.org/jbossws-tools">
       <wsdl-java file="someservice.wsdl">
       <mapping file="jaxrpc-mapping.xml" />
       </wsdl-java>
      </configuration>


      I downloaded someservice.wsdl from above url?WSDL link. I read that that the URL could be refered in a jboss-client.xml file but I will do that later.

      Now in my client I am trying to call the web service using:

      package somewebsite;
      
      import java.net.URL;
      import java.io.File;
      import org.jboss.ws.jaxrpc.ServiceFactoryImpl;
      import javax.xml.namespace.QName;
      import javax.xml.rpc.Service;
      import javax.xml.rpc.Stub;
      
      public class Test {
       public static void main(String[] args) {
       Test test = new Test();
       test.call();
       }
      
       public void call() {
       try {
       URL wsdlURL = new URL("http://someurl/someservice.asmx?WSDL");
       ServiceFactoryImpl servFactory = new ServiceFactoryImpl();
       URL mappingURL = new File("jaxrpc-mapping.xml").toURL();
       QName qname = new QName("http://somewebsite.net", "UserManagement");
       Service service = servFactory.createService(wsdlURL, qname, mappingURL);
       UserManagementSoap port = (UserManagementSoap)service.getPort(UserManagementSoap.class); GetUserList gul = new GetUserList("notfound");
       GetUserListResponse gulr = port.getUserList(gul);
       System.out.println("finished" + gulr.getGetUserListResult());
       } catch (Exception ex) {
       ex.printStackTrace();
       }
       }
      
      }
      


      I get a connection time out and don't know what is wrong? I know the web service is up and running at the url because I can hit it with a .net client. I am having problem with the java client. I am using JBOSS 4.0.4GA JBOSS WS 1.0.3GA.

      Here is the WSDL :

      <?xml version="1.0" encoding="utf-8"?>
      <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
       xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
       xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
       xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
       xmlns:tns="http://somewebsite.net/"
       xmlns:s="http://www.w3.org/2001/XMLSchema"
       xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
       xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
       targetNamespace="http://somewebsite.net/"
       xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
       <wsdl:types>
       <s:schema elementFormDefault="qualified" targetNamespace="http://somewebsite.net/">
       <s:element name="UpdateUser">
       <s:complexType>
       <s:sequence>
       <s:element minOccurs="0" maxOccurs="1" name="creatorId" type="s:string" />
       <s:element minOccurs="0" maxOccurs="1" name="input" type="s:string" />
       </s:sequence>
       </s:complexType>
       </s:element>
       <s:element name="UpdateUserResponse">
       <s:complexType>
       <s:sequence>
       <s:element minOccurs="0" maxOccurs="1" name="UpdateUserResult" type="s:string" />
       </s:sequence>
       </s:complexType>
       </s:element>
       <s:element name="DeleteUser">
       <s:complexType>
       <s:sequence>
       <s:element minOccurs="0" maxOccurs="1" name="creatorId" type="s:string" />
       <s:element minOccurs="0" maxOccurs="1" name="input" type="s:string" />
       </s:sequence>
       </s:complexType>
       </s:element>
       <s:element name="DeleteUserResponse">
       <s:complexType>
       <s:sequence>
       <s:element minOccurs="0" maxOccurs="1" name="DeleteUserResult" type="s:string" />
       </s:sequence>
       </s:complexType>
       </s:element>
       <s:element name="GetUserList">
       <s:complexType>
       <s:sequence>
       <s:element minOccurs="0" maxOccurs="1" name="creatorId" type="s:string" />
       </s:sequence>
       </s:complexType>
       </s:element>
       <s:element name="GetUserListResponse">
       <s:complexType>
       <s:sequence>
       <s:element minOccurs="0" maxOccurs="1" name="GetUserListResult" type="s:string" />
       </s:sequence>
       </s:complexType>
       </s:element>
       </s:schema>
       </wsdl:types>
       <wsdl:message name="UpdateUserSoapIn">
       <wsdl:part name="parameters" element="tns:UpdateUser" />
       </wsdl:message>
       <wsdl:message name="UpdateUserSoapOut">
       <wsdl:part name="parameters" element="tns:UpdateUserResponse" />
       </wsdl:message>
       <wsdl:message name="DeleteUserSoapIn">
       <wsdl:part name="parameters" element="tns:DeleteUser" />
       </wsdl:message>
       <wsdl:message name="DeleteUserSoapOut">
       <wsdl:part name="parameters" element="tns:DeleteUserResponse" />
       </wsdl:message>
       <wsdl:message name="GetUserListSoapIn">
       <wsdl:part name="parameters" element="tns:GetUserList" />
       </wsdl:message>
       <wsdl:message name="GetUserListSoapOut">
       <wsdl:part name="parameters" element="tns:GetUserListResponse" />
       </wsdl:message>
       <wsdl:portType name="UserManagementSoap">
       <wsdl:operation name="UpdateUser">
       <wsdl:input message="tns:UpdateUserSoapIn" />
       <wsdl:output message="tns:UpdateUserSoapOut" />
       </wsdl:operation>
       <wsdl:operation name="DeleteUser">
       <wsdl:input message="tns:DeleteUserSoapIn" />
       <wsdl:output message="tns:DeleteUserSoapOut" />
       </wsdl:operation>
       <wsdl:operation name="GetUserList">
       <wsdl:input message="tns:GetUserListSoapIn" />
       <wsdl:output message="tns:GetUserListSoapOut" />
       </wsdl:operation>
       </wsdl:portType>
       <wsdl:binding name="UserManagementSoap" type="tns:UserManagementSoap">
       <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
       <wsdl:operation name="UpdateUser">
       <soap:operation soapAction="http://somewebsite.net/UpdateUser" style="document" />
       <wsdl:input>
       <soap:body use="literal" />
       </wsdl:input>
       <wsdl:output>
       <soap:body use="literal" />
       </wsdl:output>
       </wsdl:operation>
       <wsdl:operation name="DeleteUser">
       <soap:operation soapAction="http://somewebsite.net/DeleteUser" style="document" />
       <wsdl:input>
       <soap:body use="literal" />
       </wsdl:input>
       <wsdl:output>
       <soap:body use="literal" />
       </wsdl:output>
       </wsdl:operation>
       <wsdl:operation name="GetUserList">
       <soap:operation soapAction="http://somewebsite.net/GetUserList" style="document" />
       <wsdl:input>
       <soap:body use="literal" />
       </wsdl:input>
       <wsdl:output>
       <soap:body use="literal" />
       </wsdl:output>
       </wsdl:operation>
       </wsdl:binding>
       <wsdl:binding name="UserManagementSoap12" type="tns:UserManagementSoap">
       <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
       <wsdl:operation name="UpdateUser">
       <soap12:operation soapAction="http://somewebsite.net/UpdateUser" style="document" />
       <wsdl:input>
       <soap12:body use="literal" />
       </wsdl:input>
       <wsdl:output>
       <soap12:body use="literal" />
       </wsdl:output>
       </wsdl:operation>
       <wsdl:operation name="DeleteUser">
       <soap12:operation soapAction="http://somewebsite.net/DeleteUser" style="document" />
       <wsdl:input>
       <soap12:body use="literal" />
       </wsdl:input>
       <wsdl:output>
       <soap12:body use="literal" />
       </wsdl:output>
       </wsdl:operation>
       <wsdl:operation name="GetUserList">
       <soap12:operation soapAction="http://somewebsite.net/GetUserList" style="document" />
       <wsdl:input>
       <soap12:body use="literal" />
       </wsdl:input>
       <wsdl:output>
       <soap12:body use="literal" />
       </wsdl:output>
       </wsdl:operation>
       </wsdl:binding>
       <wsdl:service name="UserManagement">
       <wsdl:port name="UserManagementSoap" binding="tns:UserManagementSoap">
       <soap:address location="http://someurl/someservice.asmx" />
       </wsdl:port>
       <wsdl:port name="UserManagementSoap12" binding="tns:UserManagementSoap12">
       <soap12:address location="http://someurl/someservice.asmx" />
       </wsdl:port>
       </wsdl:service>
      </wsdl:definitions>


      Here is the stack trace I am getting:

      org.jboss.ws.metadata.wsdl.WSDLException: java.net.ConnectException: Connection
      timed out: connect
       at org.jboss.ws.metadata.wsdl.WSDLDefinitionsFactory.getDocument(WSDLDef
      initionsFactory.java:198)
       at org.jboss.ws.metadata.wsdl.WSDLDefinitionsFactory.parse(WSDLDefinitio
      nsFactory.java:106)
       at org.jboss.ws.metadata.ServiceMetaData.getWsdlDefinitions(ServiceMetaD
      ata.java:273)
       at org.jboss.ws.deployment.JSR109ClientMetaDataBuilder.buildMetaData(JSR
      109ClientMetaDataBuilder.java:110)
       at org.jboss.ws.deployment.JSR109ClientMetaDataBuilder.buildMetaData(JSR
      109ClientMetaDataBuilder.java:82)
       at org.jboss.ws.jaxrpc.ServiceImpl.<init>(ServiceImpl.java:96)
       at org.jboss.ws.jaxrpc.ServiceFactoryImpl.createService(ServiceFactoryIm
      pl.java:157)
       at org.jboss.ws.jaxrpc.ServiceFactoryImpl.createService(ServiceFactoryIm
      pl.java:142)
       at somewebsite.Test.call(Test.java:26)
       at somewebsite.Test.main(Test.java:14)
      Caused by: java.net.ConnectException: Connection timed out: connect
       at java.net.PlainSocketImpl.socketConnect(Native Method)
       at java.net.PlainSocketImpl.doConnect(Unknown Source)
       at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
       at java.net.PlainSocketImpl.connect(Unknown Source)
       at java.net.Socket.connect(Unknown Source)
       at java.net.Socket.connect(Unknown Source)
       at sun.net.NetworkClient.doConnect(Unknown Source)
       at sun.net.www.http.HttpClient.openServer(Unknown Source)
       at sun.net.www.http.HttpClient.openServer(Unknown Source)
       at sun.net.www.http.HttpClient.<init>(Unknown Source)
       at sun.net.www.http.HttpClient.New(Unknown Source)
       at sun.net.www.http.HttpClient.New(Unknown Source)
       at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown
      Source)
       at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Sour
      ce)
       at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
       at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown So
      urce)
       at java.net.URL.openStream(Unknown Source)
       at org.jboss.ws.metadata.wsdl.WSDLDefinitionsFactory.getDocument(WSDLDef
      initionsFactory.java:181)
       ... 9 more
      


      Let me know if I am doing anything completely wrong? I didn't find any helpful example / issues in forums / wiki / jbossws guide to consume a .net service.

      Thanks


        • 1. Re: Consuming .net Web Service using JBOSSWS
          vimalm

          I was not setting the proxy server and that was the reason for the error. After doing

          -Dhttp.proxyHost=proxyserver -Dhttp.proxyPort=8080 -DproxySet=true
          


          I was able to get past this error. However I am getting another one now with this stack trace:

          org.jboss.ws.metadata.wsdl.WSDLException: java.io.IOException: Server returned H
          TTP response code: 503 for URL: http://someurl/services/usermanagement.asm
          x?WSDL
           at org.jboss.ws.metadata.wsdl.WSDLDefinitionsFactory.getDocument(WSDLDef
          initionsFactory.java:198)
           at org.jboss.ws.metadata.wsdl.WSDLDefinitionsFactory.parse(WSDLDefinitio
          nsFactory.java:106)
           at somewebsite.Test.call(Test.java:23)
           at somewebsite.Test.main(Test.java:16)
          Caused by: java.io.IOException: Server returned HTTP response code: 503 for URL:
           http://someurl/services/usermanagement.asmx?WSDL
           at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown So
          urce)
           at java.net.URL.openStream(Unknown Source)
           at org.jboss.ws.metadata.wsdl.WSDLDefinitionsFactory.getDocument(WSDLDef
          initionsFactory.java:181)
           ... 3 more
          


          A quick googling on the above error code revealed follwing link:
          http://jboss.org/index.html?module=bb&op=viewtopic&p=3963256

          Fourth reply on this topic posted the same error and somebody from JBOSS answered next that it is fixed in JBOSSWS1.0.3GA. I am using 1.0.3GA and getting this.

          I am lost??

          Any help is appreciated.

          Between I checked from my .net client that web service is up and running. So the service being unavailable is ruled out.
          [/url]

          • 2. Re: Consuming .net Web Service using JBOSSWS
            vimalm

            I got around this error. It was aparently an issue with proxy which got resolved.

            However with the current client code I am getting

            java.rmi.RemoteException: Call invocation failed with code [Client] because of: Server did not recognize the value of HTTP Header SOAPAction: .; nested exception is:
             javax.xml.rpc.soap.SOAPFaultException: Server did not recognize the value of HTTP Header SOAPAction: .
             at org.jboss.ws.jaxrpc.CallImpl.invokeInternal(CallImpl.java:713)
             at org.jboss.ws.jaxrpc.CallImpl.invoke(CallImpl.java:404)
             at org.jboss.ws.jaxrpc.CallProxy.invoke(CallProxy.java:148)
             at $Proxy0.getUserList(Unknown Source)
             at somewebsite.Test.call(Test.java:38)
             at somewebsite.Test.main(Test.java:19)
            Caused by: javax.xml.rpc.soap.SOAPFaultException: Server did not recognize the value of HTTP Header SOAPAction: .
             at org.jboss.ws.jaxrpc.SOAPFaultExceptionHelper.getSOAPFaultException(SOAPFaultExceptionHelper.java:100)
             at org.jboss.ws.binding.soap.SOAPBindingProvider.unbindResponseMessage(SOAPBindingProvider.java:486)
             at org.jboss.ws.jaxrpc.CallImpl.invokeInternal(CallImpl.java:702)
             ... 5 more
            


            Doing some research around the forums I figured I neeed to use the Call object to set this SoapAction stuff. So I modified code like

            Call call = service.createCall();
             call.setOperationName(new QName("http://somewebsite.net/", "GetUserList"));
             call.setProperty(Call.SOAPACTION_USE_PROPERTY, Boolean.TRUE);
             call.setProperty(Call.SOAPACTION_URI_PROPERTY, "http://somewebsite.net/GetUserList");
             call.setTargetEndpointAddress("http://someurl/services/usermanagement.asmx");
             GetUserList gul = new GetUserList("notfound");
             //String str = "notfound";
             Object response = call.invoke(new Object[] {gul});
            


            It still does not work with following error:

            javax.xml.rpc.JAXRPCException: Cannot obtain operation meta data for: {http://somewebsite.net/}GetUserList
             at org.jboss.ws.jaxrpc.CallImpl.getOperationMetaData(CallImpl.java:840)
             at org.jboss.ws.jaxrpc.CallImpl.getOperationMetaData(CallImpl.java:820)
             at org.jboss.ws.jaxrpc.CallImpl.invokeInternal(CallImpl.java:618)
             at org.jboss.ws.jaxrpc.CallImpl.invoke(CallImpl.java:404)
             at somewebsite.Test.call(Test.java:48)
             at somewebsite.Test.main(Test.java:19)
            


            I am lost...

            • 3. Re: Consuming .net Web Service using JBOSSWS
              vimalm

              Ok. I tried with a different service and I am getting the same error. Could somebody please help?

              Service is located at
              http://www.xmlme.com/WSAmazonBox.asmx?WSDL

              Here is the client code:

              URL wsdlURL = new URL("http://www.xmlme.com/WSAmazonBox.asmx?WSDL");
              ServiceFactoryImpl servFactory = new ServiceFactoryImpl();
              URL mappingURL = new File("jaxrpc-mapping.xml").toURL();
              QName qname = new QName("http://xmlme.com/WebServices", "AmazonBox");
              ServiceImpl service = (ServiceImpl)servFactory.createService(wsdlURL, qname, mappingURL);
              Call call = service.createCall();
              call.setOperationName(new QName("http://xmlme.com/WebServices", "DvdBox"));
              call.setProperty(Call.SOAPACTION_USE_PROPERTY, Boolean.TRUE);
              call.setProperty(Call.SOAPACTION_URI_PROPERTY, "http://xmlme.com/WebServices/DvdBox");
              call.setTargetEndpointAddress("http://www.xmlme.com/WSAmazonBox.asmx");
              DvdBox req = new DvdBox("Disney");
              Object response = call.invoke(new Object[] {req});
              if(response instanceof DvdBoxResponse) {
               DvdBoxResponse result = (DvdBoxResponse)response;
               System.out.println("Finished" + result.getDvdBoxResult());
              }
              


              Here is the exception stack trace I am getting:
              javax.xml.rpc.JAXRPCException: Cannot obtain operation meta data for: {http://xmlme.com/WebServices}DvdBox
               at org.jboss.ws.jaxrpc.CallImpl.getOperationMetaData(CallImpl.java:840)
               at org.jboss.ws.jaxrpc.CallImpl.getOperationMetaData(CallImpl.java:820)
               at org.jboss.ws.jaxrpc.CallImpl.invokeInternal(CallImpl.java:618)
               at org.jboss.ws.jaxrpc.CallImpl.invoke(CallImpl.java:404)
               at xmlme.client.Test.call(Test.java:50)
               at xmlme.client.Test.main(Test.java:21)
              


              I have generated the required artifacts from wstools. Set the proxy server settings on the command line.

              What I am doing wrong??

              Any help is appreciated.

              Thanks


              • 4. Re: Consuming .net Web Service using JBOSSWS
                vimalm

                Ok it finally worked but I am got frustrated by looking at solution.

                Aparently

                Call call = service.createCall();
                call.setOperationName(new QName ("http://xmlme.com/WebServices", "DvdBox"));
                


                is not sufficient and will give the stack trace given in my last reply. However when I tried this convoluted approach to acquire my call object it worked without the stack trace:

                Call[] calls = service.getCalls(new QName("http://xmlme.com/WebServices", "AmazonBoxSoap"));
                for(int ii=0; ii<calls.length; ii++) {
                 Call call = calls[ii];
                 QName opName = call.getOperationName();
                 if(opName.getLocalPart().equals("DvdBox")) {
                 DvdBox req = new DvdBox("Disney");
                 call.setProperty(Call.SOAPACTION_USE_PROPERTY, Boolean.TRUE);
                 call.setProperty(Call.SOAPACTION_URI_PROPERTY, "http://xmlme.com/WebServices/DvdBox");
                 Object response = call.invoke(new Object[] {req});
                 if(response instanceof DvdBoxResponse) {
                 DvdBoxResponse result = (DvdBoxResponse)response;
                 System.out.println("Finished" + result.getDvdBoxResult());
                 }
                }
                


                Here is the complete client code in case somebody runs into this issue:
                URL wsdlURL = new URL("http://www.xmlme.com/WSAmazonBox.asmx?WSDL");
                ServiceFactoryImpl servFactory = new ServiceFactoryImpl();
                URL mappingURL = new File("jaxrpc-mapping.xml").toURL();
                QName qname = new QName("http://xmlme.com/WebServices", "AmazonBox");
                ServiceImpl service = (ServiceImpl)servFactory.createService(wsdlURL, qname, mappingURL);
                Call[] calls = service.getCalls(new QName("http://xmlme.com/WebServices", "AmazonBoxSoap"));
                for(int ii=0; ii<calls.length; ii++) {
                 Call call = calls[ii];
                 QName opName = call.getOperationName();
                 if(opName.getLocalPart().equals("DvdBox")) {
                 DvdBox req = new DvdBox("Disney");
                 call.setProperty(Call.SOAPACTION_USE_PROPERTY, Boolean.TRUE);
                 call.setProperty(Call.SOAPACTION_URI_PROPERTY, "http://xmlme.com/WebServices/DvdBox");
                 Object response = call.invoke(new Object[] {req});
                 if(response instanceof DvdBoxResponse) {
                 DvdBoxResponse result = (DvdBoxResponse)response;
                 System.out.println("Finished" + result.getDvdBoxResult());
                 }
                 }
                }
                


                Have a good weekend!

                • 5. Re: Consuming .net Web Service using JBOSSWS
                  thomas.diesler

                  Instead of using painful DII. You could use wstools to generate the client side SEI and use service.getPort(MySEI.class)

                  On the dynamic proxy you should be able to make the call

                  • 6. Re: Consuming .net Web Service using JBOSSWS
                    vimalm

                    I went that route first but it did not work. I guess using DII is the only way to call .net web service from jboss-ws. I have read something in that effect on your wiki. Just don't have the link handy.

                    • 7. Re: Consuming .net Web Service using JBOSSWS
                      jason.greene

                       

                      "vimalm" wrote:
                      I went that route first but it did not work. I guess using DII is the only way to call .net web service from jboss-ws. I have read something in that effect on your wiki. Just don't have the link handy.


                      You can call a .NET service provided that it is using either document/literal or rpc/literal.

                      -Jason