简体   繁体   English

如何为Asmx Web服务编写Nusoap客户端脚本?

[英]How can i write a Nusoap client script for asmx web service?

I need a php client base on nusoap lib. 我需要基于nusoap lib的php客户端。 to get a asmx service response with haeder auth enabled: 获得启用haeder auth的asmx服务响应:

This is the Request (using soapUI): 这是请求(使用soapUI):

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:res="namespaceurl"> <soap:Header> <res:AuthHeader> <!--Optional:--> <res:UserName>myuser</res:UserName> <!--Optional:--> <res:Password>mypass</res:Password> </res:AuthHeader> </soap:Header> <soap:Body> <res:LoanStatus> <res:iAccountNbr>?</res:iAccountNbr> <res:iResortNbr>?</res:iResortNbr> <!--Optional:--> <res:strXRef></res:strXRef> </res:LoanStatus> </soap:Body> </soap:Envelope>

Here es the Response (soapUI): <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:res="namespaceurl"> <soap:Header> <res:AuthHeader> <!--Optional:--> <res:UserName>myuser</res:UserName> <!--Optional:--> <res:Password>mypass</res:Password> </res:AuthHeader> </soap:Header> <soap:Body> <res:LoanStatus> <res:iAccountNbr>?</res:iAccountNbr> <res:iResortNbr>?</res:iResortNbr> <!--Optional:--> <res:strXRef></res:strXRef> </res:LoanStatus> </soap:Body> </soap:Envelope> 这里是响应(soapUI): <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:res="namespaceurl"> <soap:Header> <res:AuthHeader> <!--Optional:--> <res:UserName>myuser</res:UserName> <!--Optional:--> <res:Password>mypass</res:Password> </res:AuthHeader> </soap:Header> <soap:Body> <res:LoanStatus> <res:iAccountNbr>?</res:iAccountNbr> <res:iResortNbr>?</res:iResortNbr> <!--Optional:--> <res:strXRef></res:strXRef> </res:LoanStatus> </soap:Body> </soap:Envelope>

If you really need to use NuSoap (I recommend using the PHP-native Soap extension!), have a look at the client samples in the Introduction to NuSoap : 如果您确实需要使用NuSoap(我建议使用PHP原生Soap扩展!),请参阅NuSoap简介中的客户端示例:

<?php
// Pull in the NuSOAP code
require_once('nusoap.php');
// Create the client instance
$client = new soapclient('http://localhost/phphack/helloworld.php');
// Call the SOAP method
$result = $client->call('hello', array('name' => 'Scott'));
// Display the result
print_r($result);
?>

From there it should be straightforward. 从那里应该很简单。

You can use nusoap to send raw XML if you are having trouble making a SOAP call to a predefined .NET Web Service. 如果无法对预定义的.NET Web服务进行SOAP调用,则可以使用nusoap发送原始XML。

Check this post for more info. 检查此帖子以获取更多信息。

However it is better to try parsing the WSDL file. 但是,最好尝试解析WSDL文件。 Try using wsdl2php. 尝试使用wsdl2php。 It is really nice for parsing WSDL files. 解析WSDL文件真的很不错。 It will replicate the data type structure from the WSDL file to a php class library. 它将数据类型结构从WSDL文件复制到php类库。

You can find a description on how to use it here . 您可以在此处找到有关如何使用它的说明。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM