2016-09-08 10 views
0

以下は私のSOAP要求であり、動作していないため、応答も貼り付けてあります。何らかの形で応答コードの代わりに、コードの下に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を使用し、それは働いた!

関連する問題