简体   繁体   English

帮助使用SOAP登录

[英]Help using SOAP for login

I'm designing a website for an organization that's a state chapter of a national organization. 我正在设计一个组织的网站,该组织是国家组织的州分会。 The national organization has implemented a member login that I need to use for the state website. 国家组织已实施了我需要用于州网站的会员登录。

My website is in PHP, and it looks like the server for the national organization is using SOAP and ColdFusion. 我的网站使用PHP,看起来该国家组织的服务器正在使用SOAP和ColdFusion。 I'm a total newbie to using SOAP, so I'm probably missing a bunch of things. 我是使用SOAP的新手,所以我可能会丢失很多东西。

The national organization sent me this information: 国家组织向我发送了以下信息:

Fields to collect on a form 表单上要收集的字段
mausername 使用者名称
mapassword mapassword

Static variables 静态变量
componenttype Value: Chapter 组件类型值:章
components Value: NM 组件值:NM
authusername Value: NMChap authusername值:NMChap
authpassword Value: USA authpassword值:美国
authpagealias Value: Login authpagealias值:登录

The webservice is located here: https://www.apta.org/AM/APTAAPPS/ComponentAuthWebService/aptamemberauthorize.cfc?WSDL 该Web服务位于以下位置: https : //www.apta.org/AM/APTAAPPS/ComponentAuthWebService/aptamemberauthorize.cfc?WSDL

The following fields will be returned: Email, FirstName, LastName, LoggedIn, Phone_Release, UserName 将返回以下字段:电子邮件,名字,姓氏,登录,电话发布,用户名

If LoggedIn returns “true,” the member has been authenticated as a member of the component. 如果LoggedIn返回“ true”,则该成员已通过身份验证为组件的成员。

This has been implemented and tested here: http://aptadevisg.apta.org/am/aptaapps/test/NM_Chap_test_form.cfm 这已在此处实现和测试: http : //aptadevisg.apta.org/am/aptaapps/test/NM_Chap_test_form.cfm

Based on this information and reading the SOAP documentation, this is what I came up with: 根据这些信息并阅读SOAP文档,这是我想到的:

$apta_server = 'https://www.apta.org/AM/APTAAPPS/ComponentAuthWebService/aptamemberauthorize.cfc?WSDL';

$post_data['mausername'] = '107150';
$post_data['mapassword'] = 'barnes';
$post_data['componenttype'] = 'Chapter';
$post_data['components'] = 'NM';
$post_data['authusername'] = 'NMChap';
$post_data['authpassword'] = 'USA';
$post_data['authpagealias'] = 'Login';

$options = array('trace' => 1, 'exceptions' => 0);
$options['location'] = 'https://www.apta.org/AM/APTAAPPS/ComponentAuthWebService/MemberAuth';

try
{
    $client = new soapclient($apta_server, $options);
}
catch (Exception $e)
{

}

$client->debug_flag = 1;

try
{
    $result = $client->__soapCall('MemberAuth', array($post_data));

    echo '<h1>Soap Result</h1><pre>';
    print_r($result);
    echo '</pre>';
}
catch (SoapFault $fault)
{
    echo '<h1>Soap Fault</h1><pre>';
    print_r($fault);
    echo '</pre>';
}

echo '<pre>getFunctions<br>';
print_r($client->__getFunctions());
echo '</pre>';

echo '<pre>getTypes<br>';
print_r($client->__getTypes());
echo '</pre>';

echo '<pre>getLastResponseHeaders<br>';
print_r($client->__getLastResponseHeaders());
echo '</pre>';

echo '<pre>getLastResponse<br>';
print_r($client->__getLastResponse());
echo '</pre>';

When I print out the result of the __soapCall(), I get a message of: "looks like we got no XML document." 当我打印__soapCall()的结果时,我收到一条消息:“看起来我们没有XML文档。”

I really don't know what I'm doing regarding SOAP, so any help would be greatly appreciated. 我真的不知道我在做什么关于SOAP的东西,因此,我们将不胜感激。 You can view the results of the test login attempt at: http://rc19.info/test_login.php 您可以在以下位置查看测试登录尝试的结果: http : //rc19.info/test_login.php

First, you have the $options['location'] wrong. 首先,您有错误的$ options ['location']。 Try the location of the actual web service: 尝试实际的Web服务的位置:

$options['location'] = 'https://www.apta.org/AM/APTAAPPS/ComponentAuthWebService/aptamemberauthorize.cfc';

Second, though not necessary, you don't have to call $client->__call("MemberAuth"). 其次,尽管不是必需的,但您不必调用$ client-> __ call(“ MemberAuth”)。 You can do $client->MemberAuth() and pass the parameters in like so: 您可以执行$ client-> MemberAuth()并像这样传递参数:

$result = $client->MemberAuth($post_data['mausername'],$post_data['mapassword'],$post_data['componenttype'],$post_data['components'],$post_data['authusername'],$post_data['authpassword'],$post_data['authpagealias']);

You've got a superfluous array in there (you could see that with $client->__lastRequest() , so change: 您那里有一个多余的array (使用$client->__lastRequest()可以看到,所以请更改:

$result = $client->__soapCall('MemberAuth', array($post_data));

To: 至:

$result = $client->__soapCall('MemberAuth', $post_data);

After that, I get either an 'could not connect to host' (if I follow the port of the WSDL, https://aptaweb.apta.org/AM/APTAAPPS/ComponentAuthWebService/aptamemberauthorize.cfc ), or a redirect (302) to the website with a bunch of cookies set if I choose yours ( https://www.apta.org/AM/APTAAPPS/ComponentAuthWebService/MemberAuth ). 之后,我得到一个“无法连接到主机”(如果我跟随WSDL的端口, https://aptaweb.apta.org/AM/APTAAPPS/ComponentAuthWebService/aptamemberauthorize.cfc )或重定向(302) )(如果我选择您的网站,则设置了一堆Cookie)( https://www.apta.org/AM/APTAAPPS/ComponentAuthWebService/MemberAuth )。 Use a stream_context with $context = stream_context_create(array('http'=>array('max_redirects'=>1))); stream_context$context = stream_context_create(array('http'=>array('max_redirects'=>1))); and $client->__getLastRequestHeaders(); $client->__getLastRequestHeaders(); to see the redirect in action. 查看重定向的实际效果。

Curiously enough, Bob's solution of https://www.apta.org/AM/APTAAPPS/ComponentAuthWebService/aptamemberauthorize.cfc works, but is in no way indicated by the wsdl itself as far as I can tell. 奇怪的是,鲍勃的https://www.apta.org/AM/APTAAPPS/ComponentAuthWebService/aptamemberauthorize.cfc解决方案有效,但据我所知,wsdl本身并没有指出。

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

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