axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Callaway, Pamela" <pcalla...@hbs.edu>
Subject RE: Webservice Client not working from inside Tomcat5
Date Thu, 24 Jan 2008 15:13:24 GMT
Hi, Thanks again for the responses.  I tried to attach the WSDL, but apparently it's too big,
so I'll just insert a snippet here.  Hopefully I got the right parts!  I did not write it,
it's from an outside vendor, so it can't be changed.  Is it okay that the namespace and qname
are not the same as the target URL?

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="http://www.perseus.com/Pdc.WS" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" targetNamespace="http://www.perseus.com/Pdc.WS"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <wsdl:types>
    <s:schema elementFormDefault="qualified" targetNamespace="http://www.perseus.com/Pdc.WS">
      <s:import namespace="http://www.w3.org/2001/XMLSchema"/>
...
      <s:element name="Login">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="userName" type="s:string"/>
            <s:element minOccurs="0" maxOccurs="1" name="password" type="s:string"/>
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="LoginResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="LoginResult" type="s:string"/>
          </s:sequence>
        </s:complexType>
      </s:element>
    </s:schema>
...
  </wsdl:types>
...
  <wsdl:message name="LoginSoapIn">
    <wsdl:part name="parameters" element="tns:Login"/>
  </wsdl:message>
  <wsdl:message name="LoginSoapOut">
    <wsdl:part name="parameters" element="tns:LoginResponse"/>
  </wsdl:message>
...
  <wsdl:portType name="ProjectDataSoap">
    <wsdl:operation name="Login">
      <documentation xmlns="http://schemas.xmlsoap.org/wsdl/">Validate the account credentials
and establish a session. This must be called before any other calls are made. Throws a SOAP
Exception if login is unsuccessful.</documentation>
      <wsdl:input message="tns:LoginSoapIn"/>
      <wsdl:output message="tns:LoginSoapOut"/>
    </wsdl:operation>
...
  </wsdl:portType>
...
<wsdl:binding name="ProjectDataSoap" type="tns:ProjectDataSoap">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
...
<wsdl:operation name="Login">
      <soap:operation soapAction="http://www.perseus.com/Pdc.WS/Login" style="document"/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
...
  </wsdl:binding>
  <wsdl:service name="ProjectData">
    <documentation xmlns="http://schemas.xmlsoap.org/wsdl/">Access to surveys and profiles.</documentation>
    <wsdl:port name="ProjectDataSoap" binding="tns:ProjectDataSoap">
      <soap:address location="http://myserver.edu/perseus/ws/projectdata.asmx"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

I used WSDL2java (Axis 1.4, what ships with Eclipse v. 3.3) to generate the=
 client, and it does look like the qname is set properly inside of the gene=
rated code.  You can also see where the soap action is set, and how it matches the soap action
in the WSDL. This is a snippet from the generated stub:

   public java.lang.String login(java.lang.String userName, java.lang.String password) throws
java.rmi.RemoteException {
        if (super.cachedEndpoint =3D=3D null) {
            throw new org.apache.axis.NoEndPointException();
        }
        org.apache.axis.client.Call _call =3D createCall();
        _call.setOperation(_operations[44]);
        _call.setUseSOAPAction(true);
        _call.setSOAPActionURI("http://www.perseus.com/Pdc.WS/Login");
        _call.setEncodingStyle(null);
        _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
        _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
        _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
        _call.setOperationName(new javax.xml.namespace.QName("http://www.perseus.com/Pdc.WS",
"Login"));

        setRequestHeaders(_call);
        setAttachments(_call);
 try {        java.lang.Object _resp =3D _call.invoke(new java.lang.Object[] {userName, password});

Thank you! (I really can't say that enough.)

Pam

-----Original Message-----
From: Martin Gainty [mailto:mgainty@hotmail.com]
Sent: Wednesday, January 23, 2008 1:02 PM
To: axis-user@ws.apache.org
Subject: Re: Webservice Client not working from inside Tomcat5

what version axis are you using?

you also need a valid epr and
 need a valid operation as qname ..

a qname consists of namespace and localpart hosts where
The namespace prefix, unless it is xml or xmlns, MUST have been declared in
a namespace declaration attribute such as
and localpart is element or attribute of the declared namespace and example
of which is
<x xmlns:edi='http://ecommerce.example.org/schema'>
  <!-- the "edi" prefix is bound to http://ecommerce.example.org/schema
       for the "x" element and contents -->
</x>

This comes from w3c.org doc located at
http://www.w3.org/TR/REC-xml-names/#dt-NSDecl

the Axis-1.4 test Client has this example:
         String endpoint =
                    "http://nagoya.apache.org:5049/axis/services/echo";
           Service  service = new Service();
           Call     call    = (Call) service.createCall();
           call.setTargetEndpointAddress( new java.net.URL(endpoint) );
           call.setOperationName(new QName("http://soapinterop.org/",
"echoString") );

If you post the wsdl we can take a more comprehensive view of the generated
service and client-stub

Martin--
----- Original Message -----
From: "Maicon Stihler" <stihler@gmail.com>
To: <axis-user@ws.apache.org>
Sent: Wednesday, January 23, 2008 12:21 PM
Subject: Re: Webservice Client not working from inside Tomcat5


> I remember having a similar problem in the past... I'm not sure if it
> is the same, but try setting up the Action header on your client to
> match that of your target web service (eg.
> options.setAction("urn:yourservice") ) and make sure it is the same
> that is on your service.xml.
>
> I think it has something to do with ws-addressing.
>
> Best Regards
>
> 2008/1/23, Callaway, Pamela <pcallaway@hbs.edu>:
> > I turned up the logging to debug level, and now I see an exception in
the log:
> > - Enter: Call::invoke()
> > - MessageContext: setTargetService(ProjectDataSoap)
> > - org.apache.axis.i18n.resource::handleGetObject(noService10)
> > - Exception:
> > org.apache.axis.ConfigurationException: No service named ProjectDataSoap
is available
> > org.apache.axis.ConfigurationException: No service named ProjectDataSoap
is available
> >         at
org.apache.axis.configuration.FileProvider.getService(FileProvider.java:233)
> >         at org.apache.axis.AxisEngine.getService(AxisEngine.java:311)
> >         at
org.apache.axis.MessageContext.setTargetService(MessageContext.java:756)
> >         at org.apache.axis.client.Call.invoke(Call.java:2690)
> >         at org.apache.axis.client.Call.invoke(Call.java:2443)
> >         at org.apache.axis.client.Call.invoke(Call.java:2366)
> >         at org.apache.axis.client.Call.invoke(Call.java:1812)
> >         at
com.xxx.www.projectdata.ProjectDataSoapStub.login(ProjectDataSoapStub.java:2
981)
> >
> > Is there something else I need to configure when trying to call the
client
> > from a JSP?  This doesn't happen when I run the JUnit test on the
client.
> >
> > Thank you!
> >
> > Pam
> >
> > -----Original Message-----
> > From: Callaway, Pamela [mailto:pcallaway@hbs.edu]
> > Sent: Wednesday, January 23, 2008 11:17 AM
> > To: axis-user@ws.apache.org
> > Subject: RE: Webservice Client not working from inside Tomcat5
> >
> > Hi, thanks for the response.  Tomcat is running as a service.  I'm not
seeing any errors in the Tomcat logs, nor am I getting any RemoteExceptions
or ServiceExceptions.  I just get back a null response from the call.  I was
able to step through in a debugger and inside the generated WSDL client as
far as the stub, and the stub gets a response that is null.   The IDs come
in okay, as far as I can tell, and when I run this locally as a JUnit test
it works...  This is the generated stub - _resp just comes back null.
> >
> > public com.xxx.www.projectdata.GetResponseResponseGetResponseResult
getResponse(int projectId, long recordId) throws java.rmi.RemoteException {
> >         if (super.cachedEndpoint == null) {
> >             throw new org.apache.axis.NoEndPointException();
> >         }
> >         org.apache.axis.client.Call _call = createCall();
> >         _call.setOperation(_operations[20]);
> >         _call.setUseSOAPAction(true);
> >         _call.setSOAPActionURI("http://www.xxx.com/Pdc.WS/GetResponse");
> >         _call.setEncodingStyle(null);
> >         _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR,
Boolean.FALSE);
> >         _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS,
Boolean.FALSE);
> >
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
> >         _call.setOperationName(new
javax.xml.namespace.QName("http://www.xxx.com/Pdc.WS", "GetResponse"));
> >
> >         setRequestHeaders(_call);
> >         setAttachments(_call);
> >  try {        java.lang.Object _resp = _call.invoke(new
java.lang.Object[] {new java.lang.Integer(projectId), new
java.lang.Long(recordId)});
> >
> >         if (_resp instanceof java.rmi.RemoteException) {
> >             throw (java.rmi.RemoteException)_resp;
> >         }
> >         else {
> >             extractAttachments(_call);
> >             try {
> >                 return
(com.xxx.www.projectdata.GetResponseResponseGetResponseResult) _resp;
> >             } catch (java.lang.Exception _exception) {
> >                 return
(com.xxx.www.projectdata.GetResponseResponseGetResponseResult)
org.apache.axis.utils.JavaUtils.convert(_resp,
com.xxx.www.projectdata.GetResponseResponseGetResponseResult.class);
> >             }
> >         }
> >   } catch (org.apache.axis.AxisFault axisFaultException) {
> >   throw axisFaultException;
> > }
> >
> > -----Original Message-----
> > From: news [mailto:news@ger.gmane.org] On Behalf Of Stephen Souness
> > Sent: Sunday, January 20, 2008 4:20 PM
> > To: axis-user@ws.apache.org
> > Subject: Re: Webservice Client not working from inside Tomcat5
> >
> > Is there anything showing up in Tomcat's logs?
> >
> > Is the Tomcat process running as a service, or as a user that may not be
> > able to establish network connections?
> >
> > Are all of the jars that the web service client requires included in
> > your web app?
> >
> >
> > --
> > Stephen
> >
> >
> > Callaway, Pamela wrote:
> > > Hi folks,
> > >
> > >
> > >
> > > I am encountering a strange problem with my webservice client that I
> > > generated using wsdl2java.  It works fine from the command line or as
a
> > > JUnit test, but when I try and use it from a JSP file, it doesn't
return
> > > a result.  Exactly the same code, no differences that I can find,
except
> > > that I want to call it from the JSP and not a JUnit test case.
> > >
> > >
> > >
> > >  I am using Tomcat5 and Java 1.5, doing my development work on a
windows
> > > box.  I wrapped the webservice up into a JAR file, which I'm then
> > > including in the web project, and I made a simple helper class so that
I
> > > could use exactly the same code to call the webservice from the JUnit
> > > test cases or from the JSP.
> > >
> > >


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Mime
View raw message