2016-09-08 2 views
0

아래는 SOAP 요청이며 작동하지 않는 경우에도 응답을 붙여 넣었습니다. 어떻게 든 코드 대신 아래 xml 응답은 WSDL xml 만 반환합니다. 나는 SOAPUI에서 같은 SOAP 요청을 시도했고 적절한 응답을 받았다.목표 C - SOAP 요청이 적절한 응답 대신 응답으로 WSDL을 반환합니다.

NSString *soapMessage = 
    @"<x:Envelope xmlns:x=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:tem=\"http://tempuri.org/\"> \ 
    <x:Header/> \ 
    <x:Body> \ 
    <tem:GetInfo> \ 
    <tem:MID>150XXXXXX693</tem:MID> \ 
    </tem:GetInfo> \ 
    </x:Body> \ 
    </x:Envelope>"; 
    NSURL *url = [NSURL URLWithString:@"http://myservice/Service.asmx?WSDL"]; 
    NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url]; 
    NSString *msgLength = [NSString stringWithFormat:@"%lu", (unsigned long)[soapMessage length]]; 

    [theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; 
    [theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"]; 
    [theRequest addValue:@"http://tempuri.org/GetInfo" forHTTPHeaderField:@"SOAPAction"]; 
    [theRequest setHTTPMethod:@"POST"]; 
    [theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]]; 
    NSURLSession *soapSession = [NSURLSession sessionWithConfiguration: [NSURLSessionConfiguration defaultSessionConfiguration] delegate:self delegateQueue:[NSOperationQueue mainQueue]]; 
    NSURLSessionDataTask *dataTask = [soapSession dataTaskWithURL: url]; 
    self.responseData = [[NSMutableData alloc]init]; 
    [dataTask resume]; 

예상 출력 내가 SOAPUI에서 가지고있는이 같은 것입니다 -

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    <soap:Body> 
     <GetInfoResponse xmlns="http://tempuri.org/"> 
     <GetInfoResult><![CDATA[<RESPONSE><REQUEST_STATUS><CODE>000</CODE><DESCRIPTION>Operation Completed Successfully</DESCRIPTION><SEVERITY>I</SEVERITY><ORIGIN>W</ORIGIN><SERIAL_NUMBER></SERIAL_NUMBER></REQUEST_STATUS><OUTPUT><Code>XXX</Code><Number>000</Number><Name>XXX</Name><AddressLine1>139 XXX E.</AddressLine1><AddressLine2>XXX 103</AddressLine2></OUTPUT></RESPONSE>]]></GetInfoResult> 
     </GetInfoResponse> 
    </soap:Body> 
</soap:Envelope> 

하지만 거대한 WSDL 자체 얻을 결과, 난 그냥 여기의 일부를 붙여 넣습니다.

<?xml version="1.0" encoding="utf-8"?> 
<wsdl:definitions xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"> 
    <wsdl:types> 
    <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/"> 
     <s:element name="GetCurrentDate"> 
     <s:complexType> 
      <s:sequence> 
      <s:element minOccurs="0" maxOccurs="1" name="MachineID" type="s:string" /> 
      </s:sequence> 
     </s:complexType> 
     </s:element> 
<s:element name="GetInfo"> 
     <s:complexType> 
      <s:sequence> 
      <s:element minOccurs="0" maxOccurs="1" name="MID" type="s:string" /> 
      </s:sequence> 
     </s:complexType> 
     </s:element> 
     <s:element name="GetInfoResponse"> 
     <s:complexType> 
      <s:sequence> 
      <s:element minOccurs="0" maxOccurs="1" name="GetInfoResult" type="s:string" /> 
      </s:sequence> 
     </s:complexType> 
     </s:element> 
</s:schema> 
    </wsdl:types> 
    <wsdl:message name="GetCurrentDateSoapIn"> 
    <wsdl:part name="parameters" element="tns:GetTradeDate" /> 
    </wsdl:message> 
<wsdl:portType name="Service"> 
<wsdl:operation name="GetInfo"> 
     <wsdl:input message="tns:GetInfoSoapIn" /> 
     <wsdl:output message="tns:GetInfoSoapOut" /> 
    </wsdl:operation> 
    </wsdl:port> 
    </wsdl:service> 
</wsdl:definitions> 

내 코드는 괜찮습니다. 오랫동안 WSDL 대신 응답을 얻지 못하고 있지만 아직 운이 없다고 생각합니다. 제발 제안 해주세요. 모든 제안을 환영합니다. 감사!

+0

문제가 무엇입니까? 명확하게 확장하십시오. –

+0

응답이 없습니다. WSDL 자체에 대한 응답을 얻습니다. – RichieRich

답변

1

이 문제가 해결되었습니다. 문제가 요청에있었습니다. 요청이 제대로 전송되지 않았고 그 이유는 내가 어떤 응답도 얻지 못했기 때문입니다. AFNetworking을 사용하여 변경했습니다.

관련 문제