2013-07-25 28 views
0

我試圖使用iOS來抽取JAX-WS SOAP 1.2 WSDL服務。我使用WSDL2ObjC轉換器將URL(下面給出的WSDL文件)轉換爲類文件。iOS中的JAX-WS服務實現

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> 

我得到了上述文件,並落實到我的項目,並嘗試使用以下值編碼來拉業務。

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]; 
    }); 

但我總是得到低於迴應。任何人都可以幫助我解決這個問題或者其他方式在iOS中使用JAX-WS服務。

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> 

回答

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);