0

I tried to pull JAX-WS SOAP 1.2 WSDL service using iOS. I used WSDL2ObjC converter to convert the url (WSDL file given below) into class files.

NSDate+ISO8601Parsing.h 
NSDate+ISO8601Parsing.m
NSDate+ISO8601Unparsing.h
NSDate+ISO8601Unparsing.m
SimpleWebServiceServiceSvc.h
SimpleWebServiceServiceSvc.m
USAdditions.h
USAdditions.m
USGlobals.h
USGlobals.m
xs.h
xs.m

<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:tns="http://sample.jaxws.ws.blog.accrd.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://sample.jaxws.ws.blog.accrd.com/" name="SimpleWebServiceService">
<types>
<xsd:schema>
<xsd:import namespace="http://sample.jaxws.ws.blog.accrd.com/" schemaLocation="http://192.168.1.45:8080/SimpleWebService/SimpleWebService?xsd=1"/>
</xsd:schema>
</types>
<message name="sayHello">
<part name="parameters" element="tns:sayHello"/>
</message>
<message name="sayHelloResponse">
<part name="parameters" element="tns:sayHelloResponse"/>
</message>
<portType name="SimpleWebService">
<operation name="sayHello">
<input wsam:Action="http://sample.jaxws.ws.blog.accrd.com/SimpleWebService/sayHelloRequest" message="tns:sayHello"/>
<output wsam:Action="http://sample.jaxws.ws.blog.accrd.com/SimpleWebService/sayHelloResponse" message="tns:sayHelloResponse"/>
</operation>
</portType>
<binding name="SimpleWebServicePortBinding" type="tns:SimpleWebService">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="sayHello">
<soap12:operation soapAction=""/>
<input>
<soap12:body use="literal"/>
</input>
<output>
<soap12:body use="literal"/>
</output>
</operation>
</binding>
<service name="SimpleWebServiceService">
<port name="SimpleWebServicePort" binding="tns:SimpleWebServicePortBinding">
<soap12:address location="http://192.168.1.45:8080/SimpleWebService/SimpleWebService"/>
</port>
</service>
</definitions>

I got above files and implemented into my project and tried to pull the service using below codings.

SimpleWebServicePortBinding *binding = [SimpleWebServiceServiceSvc SimpleWebServicePortBinding];
    binding.logXMLInOut = YES;
    SimpleWebServicePortBindingResponse *response;


    SimpleWebServiceServiceSvc_sayHello *sayHello = [[SimpleWebServiceServiceSvc_sayHello alloc] init];
    sayHello.arg0 = [[SimpleWebServiceServiceSvc_customer alloc] init];
    sayHello.arg0.firstName =    @"FirstName";
    sayHello.arg0.lastName = @"LastName";

    response = [binding sayHelloUsingParameters:sayHello];

    dispatch_async(dispatch_get_main_queue(), ^{
        [self processResponse:response];
    });

But I'm always getting below response. Can any one help me how to solve this or any other way to use JAX-WS service in iOS.

2013-07-25 12:37:59.205 LocalWSDL[1356:11303] OutputHeaders:
{
    "Content-Length" = 729;
    "Content-Type" = "application/soap+xml; charset=utf-8";
    Host = "192.168.1.45";
    SOAPAction = "";
    "User-Agent" = wsdl2objc;
}
2013-07-25 12:37:59.225 LocalWSDL[1356:11303] OutputBody:
<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:SimpleWebServiceServiceSvc="http://sample.jaxws.ws.blog.accrd.com/" xsl:version="1.0">
  <soap:Body>
    <SimpleWebServiceServiceSvc:sayHello>
      <SimpleWebServiceServiceSvc:arg0>
        <SimpleWebServiceServiceSvc:firstName>FirstName</SimpleWebServiceServiceSvc:firstName>
        <SimpleWebServiceServiceSvc:lastName>LastName</SimpleWebServiceServiceSvc:lastName>
      </SimpleWebServiceServiceSvc:arg0>
    </SimpleWebServiceServiceSvc:sayHello>
  </soap:Body>
</soap:Envelope>
2013-07-25 12:37:59.239 LocalWSDL[1356:11303] ResponseStatus: 500
2013-07-25 12:37:59.239 LocalWSDL[1356:11303] ResponseHeaders:
{
    "Content-Type" = "application/soap+xml; charset=utf-8";
    Date = "Thu, 25 Jul 2013 07:08:06 GMT";
    "Transfer-Encoding" = Identity;
}
2013-07-25 12:37:59.240 LocalWSDL[1356:11303] ResponseBody:
<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope"><S:Body><S:Fault xmlns:ns4="http://schemas.xmlsoap.org/soap/envelope/"><S:Code><S:Value>S:Receiver</S:Value></S:Code><S:Reason><S:Text xml:lang="en">java.lang.NullPointerException</S:Text></S:Reason></S:Fault></S:Body></S:Envelope>
4

1 回答 1

0

我使用http://wsclient.neurospeech.com/download/将我的 WSDL 链接转换为类。

NSWSDL.h
NSWSDL.m
SimpleWebService.h
SimpleWebService.m

然后只用了四行代码来完成我的任务。感谢 wsclient :)。这可能对某些人有用。

 SimpleWebServiceService *objService  = [SimpleWebServiceService service];
    WEcustomer *argument = [[WEcustomer alloc] init];
    argument.firstName = @"Ganesh";
    argument.lastName = @"Ananthan";
    NSError *error;
    NSString *myresult = [objService sayHello:argument error:&error];
    NSLog(@" My Result %@",myresult);
于 2013-07-25T16:44:29.437 回答