使用 PHP 调用具有多个绑定的 WCF Web 服务 [英] Using PHP to call a WCF web service with multiple bindings

查看:25
本文介绍了使用 PHP 调用具有多个绑定的 WCF Web 服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 WCF web 服务,它允许基本 HTTP 和 WS-HTTP 客户端,两者都通过 HTTPS 使用用户名 &密码认证.这是通过同一服务上的两个绑定来实现的.

I have a WCF web service which allows both Basic HTTP and WS-HTTP clients, both over HTTPS using user name & password authentication. This is achieved with two bindings on the same service.

因此,该服务位于 https://foo.com/Service.svc,基本 HTTP (SOAP 1.1) 端点是 https://foo.com/Service.svc/Unp11,WS-HTTP (SOAP 1.2) 端点是https://foo.com/Service.svc/Unp .

So, the service is at https://foo.com/Service.svc, the Basic HTTP (SOAP 1.1) endpoint is https://foo.com/Service.svc/Unp11, and the WS-HTTP (SOAP 1.2) endpoint is https://foo.com/Service.svc/Unp .

客户端尝试通过 PHP 5 访问此 Web 服务,使用其内置的 SOAP 支持,但无法连接到该服务.他不断收到 HTTP 400(错误请求)响应,如果 SOAP 消息格式错误,或者将 SOAP 1.1 消息发送到 SOAP 1.2 端点(反之亦然),就会发生这种情况.

A client is trying to access this web service via PHP 5, using its built-in SOAP support, and is having trouble connecting to the service. He keeps getting an HTTP 400 (Bad Request) response, which tends to happen if the SOAP message is badly formed, or a SOAP 1.1 message is sent to a SOAP 1.2 endpoint (or vice versa).

我只知道基本的 PHP,所以我无法帮助他.我知道你可以通过这样做来创建一个客户

I only know basic PHP so I'm having trouble helping him. I know you can create a client by doing

$client = new SoapClient('https://foo.com/Service.svc?wsdl');

但是你如何指定绑定/端点?使用 PHP 实现所有这些是否存在任何已知问题?

but how do you specify the binding/endpoint? Are there any known issues achieving all this with PHP?

更新

好的,所以我可以使用 PHP 连接到 WCF 服务 ok(在 SoapClient 构造函数中指定 SOAP 版本),并调用 $client->__getFunctions() 返回所有 Web 服务操作的正确列表.

Ok, so I can use PHP to connect to the WCF service ok (specifying the SOAP version in the SoapClient constructor), and calling $client->__getFunctions() returns a correct list of all the web service operations.

当我尝试使用 $client->__soapCall 调用一个时,页面只是在那里加载了很长时间,最终返回错误Error Fetching http headersem>".这到底是什么意思,我该如何解决?(从 .Net 客户端使用服务完美无缺.)​​

When I try to call one using $client->__soapCall, the page just sits there loading for quite a while, and eventually returns the error "Error Fetching http headers". What exactly is this supposed to mean and how do I fix it? (Consuming the service from .Net client works perfectly.)

推荐答案

今天刚遇到这个问题,为 PHP 调用者创建了一个具有多个绑定的 WCF.设置位置似乎允许 PHP 的 SoapClient 的 WSDL 版本并指定要使用的绑定.

Just ran into this today, creating a WCF with multiple bindings for a PHP caller. Setting the location appears to allow for both the WSDL version of PHP's SoapClient and specifying a binding to use.

WCF 配置是(1 个服务,2 个绑定 wsHttp 和 basicHttp),非常简单.

WCF config is (1 service with 2 bindings wsHttp and basicHttp), pretty straight-forward.

PHP 代码:

$client = new SoapClient("http://example.com/service.svc?wsdl");
$client->__setLocation("http://example.com/service.svc/basic");
$response = $client->MethodName(array( "paramName" => "paramValue" ... ));

这篇关于使用 PHP 调用具有多个绑定的 WCF Web 服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆