枪口xml请求仅返回纯文本

问题描述 投票:0回答:1

im试图在php中使用guzzle向ws发出xml请求,(并且我尝试用curl进行),但始终以纯文本形式在xml中没有响应,但响应总是在XML中)>

    $client = new \GuzzleHttp\Client(['verify' => false]);

        $soapRequest  = <<<XML
        <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/" xmlns:san="mywebsservice">                  
                <soap:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
                    <wsa:Action>http://tempuri.org/mywebsservice</wsa:Action>                   
                        <To soap:mustUnderstand="1" xmlns="http://www.w3.org/2005/08/addressing">mywebsservice </To>                    
                </soap:Header>                  
                <soap:Body>                 
                    <tem:GetSecurityToken>                  
                        <tem:request>                   
                            <san:Connection>mywebsservice</san:Connection>                  
                            <san:Passwoord>mywebsservice</san:Passwoord>                    
                            <san:System>mywebsservice</san:System>                  
                            <san:UserName>mywebsservice</san:UserName>                  
                        </tem:request>                  
                    </tem:GetSecurityToken>                 
                </soap:Body>                    
        </soap:Envelope>
XML;
        $request = $client->request('POST','mywebsservice', [
            'headers' => [
                'Content-Type' => 'application/soap+xml'
            ],
            'body' => $soapRequest                         
        ]);
        $response = $request->getBody()->getContents();
    var_dump($response);

这是回应这是响应

string(1870) "
    <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
    <s:Header>
        <a:Action s:mustUnderstand="1">http://tempuri.org/webservices/GetSecurityTokenResponse</a:Action>
        <ActivityId CorrelationId="cf1c12da-af1b-4013-ba89-25db2fa67dc1" xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">00000000-0000-0000-0000-000000000000</ActivityId>
    </s:Header>
    <s:Body>
        <GetSecurityTokenResponse xmlns="http://tempuri.org/">
            <GetSecurityTokenResult xmlns:b="webservices" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
                <b:AccessToken>token access</b:AccessToken>
                <b:IdToken>the token</b:IdToken>
                <b:TokenType>Bearer</b:TokenType>
            </GetSecurityTokenResult>
        </GetSecurityTokenResponse>
    </s:Body>
</s:Envelope>

im试图在php中使用guzzle向ws提出xml请求,(并且我尝试用curl进行),但总是以纯文本格式在xml中没有响应$ client = new \ GuzzleHttp \ Client(['verify'= > false]); ...

php xml laravel request guzzle
1个回答
0
投票

如果您这样称呼,Guzzle不会为您解码响应。

© www.soinside.com 2019 - 2024. All rights reserved.