I am trying to make my iPhone application connect to my Webservices. I don't have much experience with this Webservices so this is why I ask here for information/help.
I first tried to send XML files back and forth, well this takes too much time. Now I found out that there is an application called: wsdl2objc. It generates some objective C files but I don't have any idea how to use it.
Could someone push me in the right direction?
Below here is one of the SVC files that I open in the browser!
Metadata Service
You have created a service.
To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax:
svcutil.exe http://server/SB2/services/Metadata.svc?wsdl
This will generate a configuration file and a code file that contains the client class. Add the two files to your client application and use the generated client class to call the Service. For example:
C#
class Test
{
static void Main()
{
entitiesClient client = new entitiesClient();
// Use the 'client' variable to call operations on the service.
// Always close the client.
client.Close();
}
}
Visual Basic
Class Test
Shared Sub Main()
Dim client As entitiesClient = New entitiesClient()
' Use the 'client' variable to call operations on the service.
' Always close the client.
client.Close()
End Sub
End Class
After generating de source code, it doesn't want to compile:
- (BasicHttpBinding_entitiesBindingResponse *)RetrieveUsing;
- (void)RetrieveAsyncUsing delegate:(id<B开发者_JAVA百科asicHttpBinding_entitiesBindingResponseDelegate>)responseDelegate;
- (BasicHttpBinding_entitiesBindingResponse *)DefinedEntitiesUsing;
- (void)DefinedEntitiesAsyncUsing delegate:(id<BasicHttpBinding_entitiesBindingResponseDelegate>)responseDelegate;
Error:
error: expected ';' before 'delegate'
First, just copy the generated files into your project. Suppose your service is called ClientService and the operation is ClientOperation, there should be a class with corresponding name (ClientService.m)v - this is your starting point.
The wsdl2objc genereates necessary bindings as well as data classes according to the wsdl. If your service does require any parameters, you should be able to set up the request instance accordingly.
ClientServiceSOAPBinding * binding = [[[ClientServiceSOAPBinding alloc] initWithSOAPAddress:kSOAPServiceEndPoint] autorelease];
typens_ClientServiceRequest *request = [[ClientServiceRequestRequest new] autorelease];
ClientServiceSOAPBindingResponse *responseObj = [binding ClientOperationUsingPayload:request];
the responseObj should now hold the response from your webservice. Hope that helps,
Cheers.
EDIT:
We later found out that if a property name has a "dot" in it's name (e.g. <xs:element name="Foo.Bar"
) the wsdl2objc generator does not subsitute the dot and generated ivars contain the very same dot - the code is full of syntax errors and does not compile.
精彩评论