• 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
Cocoa: How do I send/receive XML within a HTTP connect?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Cocoa: How do I send/receive XML within a HTTP connect?


  • Subject: Cocoa: How do I send/receive XML within a HTTP connect?
  • From: email@hidden
  • Date: Fri, 16 May 2008 10:59:25 -0700 (PDT)

Hello, I'm having trouble determining the best path to follow.

Here's the schema in a nutshell:

[Mac <---- XML/SOAP -----> Server]
.. where an HTTP Post connection is created and a post/reply is synchronously generated.

I want to use Cocoa to do the equivalent in Java:

  StreamConnection xmlstream = null;
  HttpConnection connection = null;
xmlstream = (StreamConnection)Connector.open(SOAP_SERVER_URL + ";deviceside=false",Connector.READ_WRITE,true);
   ...
   OutputStream out = connection.openOutputStream();  // HttpConnection class.
   out.write(xmlreq.getBytes()); // Note: 'xmlreq' is type String.
    ...
     // ---- Get Response -----
     // Get the connection status
     status = connection.getResponseCode();  // HttpConnection class.

------------------------------

Specifically, I need to:
1) Open a read/write connection to a WSDL Soap server.    <-- using NSURLConnection?
2) Change Request Properties & Methods to reflect a POST connection.  <-- using NSMutableURLRequest?
3) Send a XML (SOAP envelope) to the Server; and   <-- ? inside NSURLConnection?
4) Get a XML response.    <-- via NSURLConnection?

This is a SYNCHRONOUS, HTTP (POST) connection.

====================

Here's my dilemma:
1) I thought about using the Core Foundation (CFNetworking) route:

       // Java equivalent: connection.setRequestProperty("Content-Type", "text/xml; charset=utf-8");

        CFHTTPMessageSetHeaderFieldValue(myRequest,CFSTR("User-Agent"), CFSTR("Apple iPhone"));
        CFHTTPMessageSetHeaderFieldValue(myRequest,CFSTR("Content-Type"), CFSTR("text/xml; charset=utf-8"));
        CFHTTPMessageSetHeaderFieldValue(myRequest,CFSTR("Accept"), CFSTR("text/html"));

But I don't know how to Synchronously Send/Receive as shown in the Java code, above.


2) If possible, I prefer to use the higher-level NSNetworking scheme: via NSMutableURLRequest.
     I can modify the request to be POST and I think I can modify the header for the Content-Type, etc.

 Do I use NSURLConnection to actually TRANSMIT & RECEIVE XML data to the Server like this?

       serverData = [NSURLConnection sendSynchronousRequest:theRequest
                                    returningResponse:serverResponse
                                    error:myError];

3) Then, how do I flush(), close() this connection?

4) or... must I try the CF route?

Regards,
Ric.
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Cocoa: How do I send/receive XML within a HTTP connect?
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: Guidance for Cocoa's steep learning curve
  • Next by Date: Re: Dynamic message typing problem
  • Previous by thread: Re: [MODERATOR] Re: WWDC ticket needed
  • Next by thread: Re: Cocoa: How do I send/receive XML within a HTTP connect?
  • Index(es):
    • Date
    • Thread