• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Web Services
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Web Services


  • Subject: Re: Web Services
  • From: Benjamin Levy <email@hidden>
  • Date: Mon, 14 Mar 2005 12:55:14 -0500

Hello,
I have a Cocoa app that uses web services and SOAP to talk to a server running the Java version of Axis (1.1). The Axis service is rpc/encoded. Complex types were a pain to figure out, and you're right that WSMakeStubs just doesn't really do anything with them. For a complex type, which on the server side is a java bean, here's what I have to do:


NSDictionary* authInfo = [[NSDictionary alloc] initWithObjectsAndKeys:
[prefs stringForKey:@"login"], @"login",
[prefs stringForKey:@"password"], @"password",
@"Mac Client SOAP 0.1", @"userAgent",
@"urn:myservice",kWSRecordNamespaceURI,
@"authInfo",kWSRecordType,nil];


Basically, I make a dictionary where the keys are the member vars of the complex type, in this case reading authentication info from prefs. Then at the end you stick a value for kWSRecordNamespaceURI and kWSRecordType. This, so far, has worked perfectly for all the main cocoa objects, including when nesting complex types.

For objects with int values, I use [NSNumber numberWithInt:x] and it seems to be encoded correctly.

The exception is NSData objects, which are not encoded properly in 10.3. In 10.3 NSData objects are serialized as xsd:base64 which isn't valid as part of http://www.w3.org/2001/XMLSchema (should be base64Binary). I reported this bug and it is supposed to be fixed in the latest Tiger posts, although I don't have the right kind of developer membership to verify it myself.

If you don't need to send binary data, then you should be okay, otherwise, my workaround for Axis was in my deploy.wsdd I have my normal service description and then a second with a different name that adds a typeMapping like this:

<service name="myservice" provider="java:RPC">
<parameter name="className" value="my.service.SOAPservice"/>
<parameter name="allowedMethods" value="*"/>
<beanMapping qname="pns:authInfo" xmlns:pns="urn:myservice"
languageSpecificType="java:my.service.authInfo"/>
<!-- other beanMappings... -->
</service>
<service name="myservice-m" provider="java:RPC">
<parameter name="className" value="my.service.SOAPservice"/>
<parameter name="allowedMethods" value="*"/>
<beanMapping qname="pns:authInfo" xmlns:pns="urn:myservice"
languageSpecificType="java:my.service.authInfo"/>
<!-- other beanMappings... -->
<typeMapping qname="xsd:base64" xmlns:xsd="http://www.w3.org/2001/XMLSchema";
languageSpecificType="java:byte[]"
serializer="org.apache.axis.encoding.ser.Base64SerializerFactory"
deserializer="org.apache.axis.encoding.ser.Base64DeserializerFactory"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";
/>
</service>


This routes the invalid base64 type that 10.3 sends to the normal de/serializers that Axis provides for base64Binary. So then my OS X client uses the service myservice-m while Java and .NET clients just use myservice.

Not sure how much this helps... the short answer is it is possible to use Web Services with Axis.

Ben

On Mar 14, 2005, at 12:02 PM, Fred McCann wrote:

I'm trying to write an OS X application as a front end to java middleware. I would like to use SOAP web services to communicate with the server. I'm running into a number of issues just getting off the ground.

1. Core Web Services seems to have problems. WSMakeStubs doesn't handle complex types well and I'm having problems getting WebServices Core to handle simple xsd:int properties on objects.

2. I've evaluated gSOAP to create web service consumers in C and C++. It took some effort to get this working. The problem I'm having here is that the results of calling web services in this fashion are C structs or C++ objects, which aren't very useful for plugging into Objective-C based widgits. To use this as a solution, it appers that I'd have to write a layer on top of gSOAP to convert C structs or C++ objects to Objective-C objects. Even for simple domain models, I can see this getting out of hand quickly.

3. I've tried using Apache Axis to create service consumers in Java. This works like a champ, but then I have to write the entire Cocoa application in Java. It's my understanding that this is somewhayt buggy and very uncommon. Also, this would shut me out of some OS X features and frameworks

4. I'm making a test right now of the axis generated stubs and calling them via the Java Bridge. This way I can have native Objective-C code and wrap the portion that does the web service communication. I'm not 100% sure that this will work or that it is feasable for a large scale project. What's mroe worrisome is that this Java Bridge is no longer supported.

So, my question is this: Is anyone connecting Cocoa applications to J2EE middleware? If you are, how are you going about it?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Web Services
      • From: Byron Wright <email@hidden>
References: 
 >Web Services (From: Fred McCann <email@hidden>)

  • Prev by Date: Makes int from pointer without cast
  • Next by Date: Re: Makes int from pointer without cast
  • Previous by thread: Web Services
  • Next by thread: Re: Web Services
  • Index(es):
    • Date
    • Thread