axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Means" <cme...@empower.com>
Subject RE: Problems with SOAP Header and .NET service
Date Wed, 23 Jul 2003 23:25:54 GMT
Hi Dims,

The setHeader method of the Stub does appear to work properly, despite my
earlier problems.  I had made a number of revisions to the WSDL2Java
generated code during previous attempts to get headers working as I
expected...these revisions had actually inhibited the correct functionality.
(I'd been removing the XMLType settings in order to match the doc/lit
requirements.)  :<

Now that I've put everything back the way it was, this code appears to be
working correctly, that is, it's now being accepted by the M$ MapPoint.NET
server despite the SOAP content being a bit more verbose than it apparently
needs to be.

Here's the functioning code snippet:

        if (getHeaders().length == 0)
        {
          CustomerInfoRouteHeader customerInfo = new CustomerInfoRouteHeader
() ;
          customerInfo.setCustomLogEntry ((short) 10) ;

          setHeader
(CustomerInfoRouteHeader.getTypeDesc().getXmlType().getNamespaceURI(),

CustomerInfoRouteHeader.getTypeDesc().getXmlType().getLocalPart(),
                     customerInfo) ;

          CultureInfo cultureInfo = new CultureInfo () ;
          cultureInfo.setName ("sv") ;

          UserInfoRouteHeader userInfo = new UserInfoRouteHeader () ;
          userInfo.setCulture (cultureInfo) ;
          userInfo.setDefaultDistanceUnit (DistanceUnit.Mile) ;

          setHeader
(UserInfoRouteHeader.getTypeDesc().getXmlType().getNamespaceURI(),

UserInfoRouteHeader.getTypeDesc().getXmlType().getLocalPart(),
                     userInfo) ;
        }

This is called from inside the Stub prior to the

	setRequestHeaders(_call);

statement.

Here's the SOAP output:

 <soapenv:Header>
  <ns1:CustomerInfoRouteHeader soapenv:mustUnderstand="0"
xsi:type="ns1:CustomerInfoRouteHeader"
xmlns:ns1="http://s.mappoint.net/mappoint-30/">
   <ns1:CustomLogEntry>10</ns1:CustomLogEntry>
  </ns1:CustomerInfoRouteHeader>
  <ns2:UserInfoRouteHeader soapenv:mustUnderstand="0"
xsi:type="ns2:UserInfoRouteHeader"
xmlns:ns2="http://s.mappoint.net/mappoint-30/">
   <ns2:Culture xsi:type="ns2:CultureInfo">
    <ns2:Name>sv</ns2:Name>
    <ns2:Lcid>0</ns2:Lcid>
   </ns2:Culture>
   <ns2:DefaultDistanceUnit>Mile</ns2:DefaultDistanceUnit>
  </ns2:UserInfoRouteHeader>
 </soapenv:Header>

Lots more verbose than it needs to be, but I can live with it for now.

I'll need to do a little work to allow the Stub to accept header objects as
properties (or create new methods that take the header objects as
parameters), but otherwise, I'm good to go.

So, no bugs to report...though I'm wondering if the next rev. of WSDL2Java
will incorporate the support of headers directly & automatically.

Question:

The Call object appears to keep prior set headers.  Will they automatically
use new property settings in the setHeader object (userInfo) or do/should I
need to rebuild the header each time the underlying header object changes?

Thanks for your help.

-Chris

> -----Original Message-----
> From: Davanum Srinivas [mailto:dims@yahoo.com]
> Sent: Wednesday, July 23, 2003 10:20 AM
> To: axis-user@ws.apache.org; cmeans@empower.com
> Subject: RE: Problems with SOAP Header and .NET service
>
>
> Last resort - Try public SOAPHeaderElement(org.w3c.dom.Element
> elem) constructor. You need to
> create the dom element by hand.
>
> This is a bug that needs to be fixed. Would appreciate if you
> could log it as one.
>
> Thanks,
> dims
>
> --- Chris Means <cmeans@empower.com> wrote:
> > Thanks, but that didn't help:
> >
> >           org.apache.axis.message.SOAPHeaderElement unknownHeader =
> >                 new
> >
> org.apache.axis.message.SOAPHeaderElement("http://s.mappoint.net/m
> appoint-30
> > /",
> >                                       "UserInfoRouteHeader",
> >                                       userInfo);
> >           unknownHeader.setMustUnderstand(true);
> >           _call.addHeader(unknownHeader);
> >
> > I get the same output:
> >
> >  <soapenv:Header>
> >   <ns1:UserInfoRouteHeader soapenv:mustUnderstand="1"
> > xsi:type="ns1:UserInfoRouteHeader"
> > xmlns:ns1="http://s.mappoint.net/mappoint-30/">
> >    <DefaultDistanceUnit>Mile</DefaultDistanceUnit>
> >   </ns1:UserInfoRouteHeader>
> >  </soapenv:Header>
> >
> > Any other suggestions?
> >
> > I appreciate the help!
> >
> > -Chris
> >
> > > -----Original Message-----
> > > From: Davanum Srinivas [mailto:dims@yahoo.com]
> > > Sent: Wednesday, July 23, 2003 8:43 AM
> > > To: cmeans@empower.com; axis-user@ws.apache.org
> > > Subject: RE: Problems with SOAP Header and .NET service
> > >
> > >
> > > Try the following to add headers...
> > >         SOAPHeaderElement unknownHeader =
> > >                 new SOAPHeaderElement("http://example.org",
> > >                                       "unknown",
> > >                                       "Nobody understands me!");
> > >         unknownHeader.setMustUnderstand(true);
> > >         _call.addHeader(unknownHeader);
> > >
> > > -- dims
> > >
> > > Excerpt from:
> > > http://cvs.apache.org/viewcvs/xml-axis/java/test/wsdl/soap12/addit
> > ional/WhiteMesaSoap12AddTestSvcTestCase.java
> > >
> > > --- Chris Means <cmeans@empower.com> wrote:
> > > > Yes.
> > > >
> > > > None of the Java/Axis projects appear to use SOAP Headers.
> > > >
> > > > Here's a snippet from one of the source files:
> > > >
> > > >       // Call the MapPoint .NET server to calculate the route.
> > > >       // Unfortunately, Axis doesn't let us pass a
> UserInfoRouteHeader
> > > >       // to the route service, so we cannot specify the
> > > distance units to
> > > >       // use for the route.  Instead, we use the default
> > > (kilometers) and
> > > >       // convert to the desired units in the
> DrivingDirectionsWindow.
> > > >
> > > > Are you aware of one that does?  Or is there something I missed?
> > > >
> > > > > -----Original Message-----
> > > > > From: Davanum Srinivas [mailto:dims@yahoo.com]
> > > > > Sent: Wednesday, July 23, 2003 5:54 AM
> > > > > To: axis-user@ws.apache.org; cmeans@empower.com
> > > > > Subject: Re: Problems with SOAP Header and .NET service
> > > > >
> > > > >
> > > > > Did you see the code posted by these guys?
> http://demo.mappoint.net/
> > > > >
> > > > > -- dims
> > > > >
> > > > > --- Chris Means <cmeans@empower.com> wrote:
> > > > > > Hi,
> > > > > >
> > > > > > I've been bashing my head against the wall trying to figure
> > > > > this out...it's
> > > > > > not as helpful as reading the documentation, but it hurts just
> > > > > as much <g>.
> > > > > >
> > > > > > I'm successfully using an Axis 1.1 client to talk to a .NET
> > > > > service.  The
> > > > > > WSDL2Java tool worked well for the most part, but there
> > > were one or two
> > > > > > tweaks I had to make as Axis doesn't yet appear to support the
> > > > > <list> type
> > > > > > that M$ loves so much.
> > > > > >
> > > > > > My remaining stumbling block appears to be with sending the
> > > > > SOAP Headers the
> > > > > > way .NET wants to get them.  (The SOAP Body is perfect.)
> > > > > >
> > > > > > I've successfully been using the setHeader method of the
> > > Stub to add new
> > > > > > headers, however, Axis keeps adding xsi:type attributes,
> > > > > despite the fact
> > > > > > that I've got:
> > > > > >
> > > > > >
> > > _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR,
> > > > > > Boolean.FALSE);
> > > > > >
> > > > > > (Does this setting not apply to headers added via the Stub?
> > >  I did try
> > > > > > adding a header via _call.addHeader, but that didn't seem to
do
> > > > > the trick
> > > > > > either.)
> > > > > >
> > > > > > So, instead of getting:
> > > > > >
> > > > > >  <soapenv:Header>
> > > > > >   <UserInfoRouteHeader
> xmlns="http://s.mappoint.net/mappoint-30/">
> > > > > >    <DefaultDistanceUnit>Mile</DefaultDistanceUnit>
> > > > > >   </UserInfoRouteHeader>
> > > > > >  </soapenv:Header>
> > > > > >
> > > > > > I get:
> > > > > >
> > > > > >  <soapenv:Header>
> > > > > >   <ns1:UserInfoRouteHeader soapenv:mustUnderstand="0"
> > > > > > xsi:type="ns1:UserInfoRouteHeader"
> > > > > > xmlns:ns1="http://s.mappoint.net/mappoint-30/">
> > > > > >    <DefaultDistanceUnit>Mile</DefaultDistanceUnit>
> > > > > >   </ns1:UserInfoRouteHeader>
> > > > > >  </soapenv:Header>
> > > > > >
> > > > > > Here's how I'm adding the header:
> > > > > >
> > > > > >           UserInfoRouteHeader userInfo = new
> > > UserInfoRouteHeader () ;
> > > > > >           userInfo.setDefaultDistanceUnit (DistanceUnit.Mile)
;
> > > > > >
> > > > > >           setHeader ("http://s.mappoint.net/mappoint-30/",
> > > > > >                      "UserInfoRouteHeader",
> > > > > >                      userInfo) ;
> > > > > >
> > > > > > Can anyone point me in the right direction?
> > > > > >
> > > > > > Thanks.
> > > > > >
> > > > > > -Chris
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > > =====
> > > > > Davanum Srinivas - http://webservices.apache.org/~dims/
> > > > >
> > > > > __________________________________
> > > > > Do you Yahoo!?
> > > > > Yahoo! SiteBuilder - Free, easy-to-use web site design software
> > > > > http://sitebuilder.yahoo.com
> > > > >
> > > >
> > > >
> > >
> > >
> > > =====
> > > Davanum Srinivas - http://webservices.apache.org/~dims/
> > >
> > > __________________________________
> > > Do you Yahoo!?
> > > Yahoo! SiteBuilder - Free, easy-to-use web site design software
> > > http://sitebuilder.yahoo.com
> > >
> >
> >
> >
>
>
> =====
> Davanum Srinivas - http://webservices.apache.org/~dims/
>
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software
> http://sitebuilder.yahoo.com
>



Mime
View raw message