带参数的asmx HTTP Post请求

时间:2017-02-12 08:35:24

标签: php soap http-post asmx

我们公司有一个.net基础网站
几天前,我们要求网站程序员提供网络服务,昨天他给我发了一个URL 当我从localhost打开URL时,它显示了一个页面,我可以选择我要求编程的四个方法(函数)之一。
通过选择其中一个,新页面显示如下:

SOAP 1.1
以下是SOAP 1.1请求和响应示例。显示的占位符需要替换为实际值。

  

POST /webservices/findstatus.asmx HTTP / 1.1主机:localhost
  Content-Type:text / xml; charset = utf-8内容长度:长度
  SOAPAction:" http://tempuri.org/FindWith_CodeR_Serail"

<?xml version="1.0" encoding="utf-8"?>  
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">  
  <soap:Body>  
    <FindWith_CodeR_Serail xmlns="http://tempuri.org/">  
      <CodeReception>int</CodeReception>  
      <Serial>string</Serial>  
    </FindWith_CodeR_Serail>  
  </soap:Body>  
</soap:Envelope>  
  

HTTP / 1.1 200 OK内容类型:text / xml;字符集= UTF-8
  内容长度:长度

<?xml version="1.0" encoding="utf-8"?>  
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">  
  <soap:Body>  
    <FindWith_CodeR_SerailResponse xmlns="http://tempuri.org/">  
      <FindWith_CodeR_SerailResult>string</FindWith_CodeR_SerailResult>  
    </FindWith_CodeR_SerailResponse>  
  </soap:Body>  
</soap:Envelope> 

SOAP 1.2
以下是SOAP 1.2请求和响应示例。显示的占位符需要替换为实际值。

  

POST /webservices/findstatus.asmx HTTP / 1.1主机:localhost
  Content-Type:application / soap + xml; charset = utf-8内容长度:   长度

<?xml version="1.0" encoding="utf-8"?>  
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">  
  <soap12:Body>  
    <FindWith_CodeR_Serail xmlns="http://tempuri.org/">  
      <CodeReception>int</CodeReception>  
      <Serial>string</Serial>  
    </FindWith_CodeR_Serail>  
  </soap12:Body>  
</soap12:Envelope>  
  

HTTP / 1.1 200 OK内容类型:application / soap + xml;字符集= UTF-8
  内容长度:长度

<?xml version="1.0" encoding="utf-8"?>  
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">  
  <soap12:Body>  
    <FindWith_CodeR_SerailResponse xmlns="http://tempuri.org/">  
      <FindWith_CodeR_SerailResult>string</FindWith_CodeR_SerailResult>  
    </FindWith_CodeR_SerailResponse>  
  </soap12:Body>  
</soap12:Envelope> 

HTTP POST
以下是HTTP POST请求和响应示例。显示的占位符需要替换为实际值。

  

POST /webservices/findstatus.asmx/FindWith_CodeR_Serail HTTP / 1.1
  主持人:localhost内容类型:application / x-www-form-urlencoded
  Content-Length:length CodeReception = string&amp; Serial = string
  HTTP / 1.1 200 OK内容类型:text / xml;字符集= UTF-8
  内容长度:长度

<?xml version="1.0" encoding="utf-8"?>  
<string xmlns="http://tempuri.org/">string</string>  

现在我使用2个参数来调用这个Web服务的php代码 请发给我完整的代码,我可以将其粘贴到php文件中进行测试。 无论使用何种方法:SOAP或HTTP POST

请帮帮我。

我使用了这个PHP代码,一切都还可以:

<?php

$client = new SoapClient("http://www.MyWebSite.com/webservices/findstatus.asmx?WSDL");
$params=new stdClass();
$params->CodeReception = '11111';
$params->Serial = '22222222';    
$result = $client->FindWith_CodeR_Serail($params)->FindWith_CodeR_SerailResult;
echo  $result;
?>

1 个答案:

答案 0 :(得分:1)

<?php

$client = new SoapClient("http://www.MyWebSite.com/webservices/findstatus.asmx?WSDL");
$params=new stdClass();
$params->CodeReception = '11111';
$params->Serial = '22222222';    
$result = $client->FindWith_CodeR_Serail($params)->FindWith_CodeR_SerailResult;
echo  $result;
?>
相关问题