简体   繁体   中英

What flavor of SOAP is defined by this WSDL, and how to consume it with PHP?

We have a PHP application which needs to connect to this SOAP web service—here's the WSDL: https://arixss.arifleet.com/QA/DriveAwayWS/DriveAwaySrvc.svc?wsdl

The vendor claims it uses "WS-Security (wsHttpBinding)". This doesn't mean much to me, as I don't have experience beyond "normal" unauthenticated SOAP. Furthermore, I understand there are probably several ways to implement WS-Security, and the vendor hasn't provided a full specification.

So far, thanks to the WSSoap class given in this answer , I have been able to connect, authenticate, and run the GetAllRequests method successfully. However, I'm stuck when trying to run the GetRequestDetail method, because I don't know what kind of parameter argument to use. The vendor offers this snippet of .NET code as an example:

DriveAwayClient client = new DriveAwayClient();
client.ClientCredentials.UserName.UserName = "…";
client.ClientCredentials.UserName.Password = "…";
ARIRqst rqst = new ARIRqst();
rqst.RqstType = "ORDER";
rqst.OrderID = "12345";
string RequestDetail;
RequestDetail = client.GetRequestDetail(rqst);

This code can't be rewritten in PHP (at least using the WSSoap class) because I have no way of injecting a ARIRqst object using WSSoap. Furthermore, I wouldn't know how to instantiate a ARIRqst object, because I don't have access to a ARIRqst() class in PHP.

I thought if I knew more about the specific requirements of this web service, as defined by the WSDL—what its specific type is, and what authentication is used—I would have better luck finding an example in PHP which can consume it, or at least find the specifications so that I could write my own implementation.

UPDATE: To be specific, I ultimately just need to know how to format the request for this web service's GetRequestDetail method. Here's what I'm sending:

<?xml version="1.0"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://tempuri.org/">
    <s:Header>
        <a:Action s:mustUnderstand="1">http://tempuri.org/IDriveAway/GetRequestDetail</a:Action>
        <a:MessageID>urn:uuid:eacedde2-cec5-4da1-afbf-822fe2e92793</a:MessageID>
        <a:ReplyTo>
            <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
        </a:ReplyTo>
        <a:To s:mustUnderstand="1">https://arixss.arifleet.com/QA/DriveAwayWS/DriveAwaySrvc.svc?wsdl</a:To>
        <o:Security xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" s:mustUnderstand="1">
            <u:Timestamp u:Id="_0">
                <u:Created>2014-04-08T23:20:00Z</u:Created>
                <u:Expires>2014-04-08T23:25:00Z</u:Expires>
            </u:Timestamp>
            <c:SecurityContextToken xmlns:c="http://schemas.xmlsoap.org/ws/2005/02/sc" u:Id="uuid-85c09ef0-83e1-417c-b9c7-5892798ee739-197">
                <c:Identifier>urn:uuid:24d56285-84f1-4c74-8093-5f72090ab92f</c:Identifier>
            </c:SecurityContextToken>
            <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
                <SignedInfo>
                    <CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
                    <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#hmac-sha1"/>
                    <Reference URI="#_0">
                        <Transforms>
                            <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
                        </Transforms>
                        <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
                        <DigestValue>[REDACTED]</DigestValue>
                    </Reference>
                </SignedInfo>
                <SignatureValue>[REDACTED]</SignatureValue>
                <KeyInfo>
                    <o:SecurityTokenReference>
                        <o:Reference ValueType="http://schemas.xmlsoap.org/ws/2005/02/sc/sct" URI="#uuid-85c09ef0-83e1-417c-b9c7-5892798ee739-197"/>
                    </o:SecurityTokenReference>
                </KeyInfo>
            </Signature>
        </o:Security>
    </s:Header>
    <s:Body>
        <ns1:GetRequestDetail xsi:type="ns1:ARIRqst">
            <RqstType>ORDER</RqstType>
            <RqstID>1234</RqstID>
            <OrderID>1234-1</OrderID>
            <QuoteID>1</QuoteID>
        </ns1:GetRequestDetail>
    </s:Body>
</s:Envelope>

And here is the response from the server, containing an InternalServiceFault of "Object reference not set to an instance of an object" (which I assume means I'm not encoding the ARIRqst object correctly in the request):

<?xml version="1.0"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <s:Header>
        <a:Action s:mustUnderstand="1">http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher/fault</a:Action>
        <a:RelatesTo>urn:uuid:c0af2ed0-9afb-4c77-a09f-2463bf5cbc52</a:RelatesTo>
        <o:Security xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" s:mustUnderstand="1">
            <u:Timestamp u:Id="_0">
                <u:Created>2014-04-08T23:20:26.872Z</u:Created>
                <u:Expires>2014-04-08T23:25:26.872Z</u:Expires>
            </u:Timestamp>
        </o:Security>
    </s:Header>
    <s:Body>
        <s:Fault>
            <s:Code>
                <s:Value>s:Receiver</s:Value>
                <s:Subcode>
                    <s:Value xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:InternalServiceFault</s:Value>
                </s:Subcode>
            </s:Code>
            <s:Reason>
                <s:Text xml:lang="en-US">Object reference not set to an instance of an object.</s:Text>
            </s:Reason>
            <s:Detail>
                <ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
                    <HelpLink i:nil="true"/>
                    <InnerException i:nil="true"/>
                    <Message>Object reference not set to an instance of an object.</Message>
                    <StackTrace>   at ARI.DriveAwayMgr.DriveAwaySrvc.GetRequestDetail(ARIRqst rqst) in d:\[REDACTED]\DriveAwaySrvc.svc.cs:line 189&#xD;
   at SyncInvokeGetRequestDetail(Object , Object[] , Object[] )&#xD;
   at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]&amp; outputs)&#xD;
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc)&#xD;
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp; rpc)&#xD;
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc&amp; rpc)&#xD;
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&amp; rpc)&#xD;
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&amp; rpc)&#xD;
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc&amp; rpc)&#xD;
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc&amp; rpc)&#xD;
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc&amp; rpc)&#xD;
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc&amp; rpc)&#xD;
   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</StackTrace>
                    <Type>System.NullReferenceException</Type>
                </ExceptionDetail>
            </s:Detail>
        </s:Fault>
    </s:Body>
</s:Envelope>
<?php
$client = new SoapClient('http://soap.amazon.com/schemas3/AmazonWebServices.wsdl');
var_dump($client->__getFunctions());
?>

From php.net.

Just insert the wsdl into the SoapClient call...it should return all methods and parameters...

You can wrap it in a try catch block also

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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