Page 1 of 1

Soap Client is not working after editing the request header

Posted: Tue Feb 14, 2017 1:13 am
by ebinjames007
I am using php SOAP Client. Also am edited the request header before sending using HackySoapClient extended from SoapClient.I edited the request header because the server accept only custom header . When i call the method i got a blank screen . Is there any mistake with my code .I checked the php log for any error/new request,Got the following error.

***[Tue Feb 14 11:58:26.832268 2017] [:error] [pid 1808:tid 1080] [client ::1:30344] PHP Fatal error: SOAP-ERROR: Parsing Schema: element 'urn:oasis:names:tc:ebxml-regrep:xsd:query:3.0:ResponseOption' already defined in D:\\web\\Apache24\\htdocs\\test\\testconnect1.php on line 281***

can anyone help regarding this issue?
This is the code i am currently using .

Code: Select all

    //require('xmltoarray_parser_htmlfix.php');
    $issueInstant = $authnInstant = date("Y-m-d\TH:i:s\Z", strtotime(gmdate("Y-m-d H:i:s"))-300);
    $expired = date("Y-m-d\TH:i:s\Z", strtotime(gmdate("Y-m-d H:i:s"))+300);
    $current_date = gmdate('YmdHis');
    class HackySoapClient extends \SoapClient {
    
        function __doRequest( $request, $location, $action, $version, $one_way = 0 ) {    
    
              $request = str_replace( '<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="urn:hl7-org:v3">', '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:urn="urn:gov:hhs:fha:nhinc:common:nhinccommonentity" xmlns:urn1="urn:oasis:names:tc:ebxml-regrep:xsd:query:3.0" xmlns:urn2="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0" xmlns:urn3="urn:gov:hhs:fha:nhinc:common:nhinccommon">', $request );
              $request = str_replace( '<env:Header></env:Header>', '<soap:Header/>', $request );
              $request = str_replace( '<env:Body>', '<soap:Body >', $request );
              //  $request = str_replace( ' xmlns:ns1="' . $namespace . '"', '', $request );
              return parent::__doRequest( $request, $location, $action, $version, $one_way = 0 );
        }
    }
    $body = '<urn:RespondingGateway_CrossGatewayQueryRequest>
             <urn1:AdhocQueryRequest federated="false" startIndex="0" maxResults="-1">
                <urn1:ResponseOption returnType="LeafClass" returnComposedObjects="false"/>
                <urn2:AdhocQuery home="urn:oid:1.1" id="urn:uuid:14d4debf-8f97-4251-9a74-a90016b0af0d">
                   <urn2:Slot name="$XDSDocumentEntryPatientId">
                      <urn2:ValueList>
                         <urn2:Value>"D123401^^^&1.1&ISO"</urn2:Value>
                      </urn2:ValueList>
                   </urn2:Slot>
                   <urn2:Slot name="$XDSDocumentEntryStatus">
                      <urn2:ValueList>
                         <urn2:Value>("urn:oasis:names:tc:ebxml-regrep:StatusType:Approved")</urn2:Value>
                      </urn2:ValueList>
                   </urn2:Slot>
             <urn2:Slot name="$XDSDocumentEntryClassCode">
                <urn2:ValueList>
                        <urn2:Value>34133-9</urn2:Value>
                      </urn2:ValueList>
                   </urn2:Slot>
                   <urn2:Slot name="$XDSDocumentEntryClassCodeScheme">
                      <urn2:ValueList>
                         <urn2:Value>2.16.840.1.113883.6.1</urn2:Value>
                      </urn2:ValueList>
                   </urn2:Slot>
                </urn2:AdhocQuery>
             </urn1:AdhocQueryRequest>
             <urn:assertion>
                <urn3:nationalProviderId>1234567890</urn3:nationalProviderId>         
                <urn3:address xmlns:urn1="urn:gov:hhs:fha:nhinc:common:nhinccommon">
                   <urn3:addressType>
                      <urn3:code>AddrCode</urn3:code>
                      <urn3:codeSystem>AddrCodeSyst</urn3:codeSystem>
                      <urn3:codeSystemName>AddrCodeSystName</urn3:codeSystemName>
                      <urn3:codeSystemVersion>1.0</urn3:codeSystemVersion>
                      <urn3:displayName>AddrCode</urn3:displayName>
                      <urn3:originalText>AddrCode</urn3:originalText>
                   </urn3:addressType>
                   <urn3:city>AddrCity</urn3:city>
                   <urn3:country>AddrCountry</urn3:country>
                   <urn3:state>AddrState</urn3:state>
                   <urn3:streetAddress>AddrStreet</urn3:streetAddress>
                   <urn3:zipCode>AddrZip</urn3:zipCode>
                </urn3:address>
                <urn3:dateOfBirth xmlns:urn1="urn:gov:hhs:fha:nhinc:common:nhinccommon">06/04/1959 05:21:00</urn3:dateOfBirth>
                <urn3:explanationNonClaimantSignature xmlns:urn1="urn:gov:hhs:fha:nhinc:common:nhinccommon">Electronic</urn3:explanationNonClaimantSignature>
                <urn3:haveSecondWitnessSignature xmlns:urn1="urn:gov:hhs:fha:nhinc:common:nhinccommon">false</urn3:haveSecondWitnessSignature>
                <urn3:haveSignature xmlns:urn1="urn:gov:hhs:fha:nhinc:common:nhinccommon">false</urn3:haveSignature>
                <urn3:haveWitnessSignature xmlns:urn1="urn:gov:hhs:fha:nhinc:common:nhinccommon">false</urn3:haveWitnessSignature>
                <urn3:homeCommunity xmlns:urn1="urn:gov:hhs:fha:nhinc:common:nhinccommon">
                   <urn3:description>${#Project#LocalHCDescription}</urn3:description>
                   <urn3:homeCommunityId>2.16.840.1.113883.3.3502</urn3:homeCommunityId>
                   <urn3:name>${#Project#LocalHCDescription}</urn3:name>
                </urn3:homeCommunity>
                <urn3:personName xmlns:urn1="urn:gov:hhs:fha:nhinc:common:nhinccommon">
                   <urn3:familyName>Smith</urn3:familyName>
                   <urn3:givenName>Sandy</urn3:givenName>
                   <urn3:nameType>
                      <urn3:code>nameCode</urn3:code>
                      <urn3:codeSystem>nameCodeSyst</urn3:codeSystem>
                      <urn3:codeSystemName>nameCodeSystName</urn3:codeSystemName>
                      <urn3:codeSystemVersion>1.0</urn3:codeSystemVersion>
                      <urn3:displayName>nameCode</urn3:displayName>
                      <urn3:originalText>nameCode</urn3:originalText>
                   </urn3:nameType>
                   <urn3:secondNameOrInitials>S</urn3:secondNameOrInitials>
                   <urn3:fullName>Sandy S. Smith</urn3:fullName>
                </urn3:personName>
                <urn3:phoneNumber xmlns:urn1="urn:gov:hhs:fha:nhinc:common:nhinccommon">
                   <urn3:areaCode>321</urn3:areaCode>
                   <urn3:countryCode>1</urn3:countryCode>
                   <urn3:extension>5436</urn3:extension>
                   <urn3:localNumber>253-6849</urn3:localNumber>
                   <urn3:phoneNumberType>
                      <urn3:code>phoneCode</urn3:code>
                      <urn3:codeSystem>phoneCodeSyst</urn3:codeSystem>
                      <urn3:codeSystemName>phoneCodeSystName</urn3:codeSystemName>
                      <urn3:codeSystemVersion>1.0</urn3:codeSystemVersion>
                      <urn3:displayName>phoneCode</urn3:displayName>
                      <urn3:originalText>phoneCode</urn3:originalText>
                   </urn3:phoneNumberType>
                </urn3:phoneNumber>
                <urn3:secondWitnessAddress xmlns:urn1="urn:gov:hhs:fha:nhinc:common:nhinccommon">
                   <urn3:addressType>
                      <urn3:code>AddrCode</urn3:code>
                      <urn3:codeSystem>AddrCodeSyst</urn3:codeSystem>
                      <urn3:codeSystemName>AddrCodeSystName</urn3:codeSystemName>
                      <urn3:codeSystemVersion>1.0</urn3:codeSystemVersion>
                      <urn3:displayName>AddrCode</urn3:displayName>
                      <urn3:originalText>AddrCode</urn3:originalText>
                   </urn3:addressType>
                   <urn3:city>Addr2City</urn3:city>
                   <urn3:country>Addr2Country</urn3:country>
                   <urn3:state>Addr2State</urn3:state>
                   <urn3:streetAddress>Addr2Street</urn3:streetAddress>
                   <urn3:zipCode>Addr2Zip</urn3:zipCode>
                </urn3:secondWitnessAddress>
                <urn3:secondWitnessName xmlns:urn1="urn:gov:hhs:fha:nhinc:common:nhinccommon">
                   <urn3:familyName>Smith</urn3:familyName>
                   <urn3:givenName>Sammy</urn3:givenName>
                   <urn3:nameType>
                      <urn3:code>nameCode</urn3:code>
                      <urn3:codeSystem>nameCodeSyst</urn3:codeSystem>
                      <urn3:codeSystemName>nameCodeSystName</urn3:codeSystemName>
                      <urn3:codeSystemVersion>1.0</urn3:codeSystemVersion>
                      <urn3:displayName>nameCode</urn3:displayName>
                      <urn3:originalText>nameCode</urn3:originalText>
                   </urn3:nameType>
                   <urn3:secondNameOrInitials>s</urn3:secondNameOrInitials>
                   <urn3:fullName>Sammy S. Smith</urn3:fullName>
                </urn3:secondWitnessName>
                <urn3:secondWitnessPhone xmlns:urn1="urn:gov:hhs:fha:nhinc:common:nhinccommon">
                   <urn3:areaCode>321</urn3:areaCode>
                   <urn3:countryCode>1</urn3:countryCode>
                   <urn3:extension>5424</urn3:extension>
                   <urn3:localNumber>542-6823</urn3:localNumber>
                   <urn3:phoneNumberType>
                      <urn3:code>phoneCode</urn3:code>
                      <urn3:codeSystem>phoneCodeSyst</urn3:codeSystem>
                      <urn3:codeSystemName>phoneCodeSystName</urn3:codeSystemName>
                      <urn3:codeSystemVersion>1.0</urn3:codeSystemVersion>
                      <urn3:displayName>phoneCode</urn3:displayName>
                      <urn3:originalText>phoneCode</urn3:originalText>
                   </urn3:phoneNumberType>
                </urn3:secondWitnessPhone>
                <urn3:SSN xmlns:urn1="urn:gov:hhs:fha:nhinc:common:nhinccommon">253-98-7546</urn3:SSN>
                <urn3:uniquePatientId xmlns:urn1="urn:gov:hhs:fha:nhinc:common:nhinccommon">500000000^^^&1.1&ISO</urn3:uniquePatientId>
                <urn3:witnessAddress xmlns:urn1="urn:gov:hhs:fha:nhinc:common:nhinccommon">
                   <urn3:addressType>
                      <urn3:code>addrCode</urn3:code>
                      <urn3:codeSystem>addrCodeSyst</urn3:codeSystem>
                      <urn3:codeSystemName>addrCodeSystName</urn3:codeSystemName>
                      <urn3:codeSystemVersion>1.0</urn3:codeSystemVersion>
                      <urn3:displayName>addrCode</urn3:displayName>
                      <urn3:originalText>addrCode</urn3:originalText>
                   </urn3:addressType>
                   <urn3:city>Burnell</urn3:city>
                   <urn3:country>USA</urn3:country>
                   <urn3:state>FL</urn3:state>
                   <urn3:streetAddress>825 North</urn3:streetAddress>
                   <urn3:zipCode>32184</urn3:zipCode>
                </urn3:witnessAddress>
                <urn3:witnessName xmlns:urn1="urn:gov:hhs:fha:nhinc:common:nhinccommon">
                   <urn3:familyName>Smith</urn3:familyName>
                   <urn3:givenName>Scott</urn3:givenName>
                   <urn3:nameType>
                      <urn3:code>nameCode</urn3:code>
                      <urn3:codeSystem>nameCodeSyst</urn3:codeSystem>
                      <urn3:codeSystemName>nameCodeSystName</urn3:codeSystemName>
                      <urn3:codeSystemVersion>1.0</urn3:codeSystemVersion>
                      <urn3:displayName>nameCode</urn3:displayName>
                      <urn3:originalText>nameCode</urn3:originalText>
                   </urn3:nameType>
                   <urn3:secondNameOrInitials>S.</urn3:secondNameOrInitials>
                   <urn3:fullName>Scott S. Smith</urn3:fullName>
                </urn3:witnessName>
                <urn3:witnessPhone xmlns:urn1="urn:gov:hhs:fha:nhinc:common:nhinccommon">
                   <urn3:areaCode>321</urn3:areaCode>
                   <urn3:countryCode>1</urn3:countryCode>
                   <urn3:extension>8432</urn3:extension>
                   <urn3:localNumber>985-2239</urn3:localNumber>
                   <urn3:phoneNumberType>
                      <urn3:code>phoneCode</urn3:code>
                      <urn3:codeSystem>phoneCodeSyst</urn3:codeSystem>
                      <urn3:codeSystemName>phoneCodeSystName</urn3:codeSystemName>
                      <urn3:codeSystemVersion>1.0</urn3:codeSystemVersion>
                      <urn3:displayName>phoneCode</urn3:displayName>
                      <urn3:originalText>phoneCode</urn3:originalText>
                   </urn3:phoneNumberType>
                </urn3:witnessPhone>
                <urn3:userInfo xmlns:urn1="urn:gov:hhs:fha:nhinc:common:nhinccommon">
                   <urn3:personName>
                      <urn3:familyName>Skagerberg</urn3:familyName>
                      <urn3:givenName>Karl</urn3:givenName>
                      <urn3:nameType>
                         <urn3:code>nameCode</urn3:code>
                         <urn3:codeSystem>nameCodeSyst</urn3:codeSystem>
                         <urn3:codeSystemName>nameCodeSystName</urn3:codeSystemName>
                         <urn3:codeSystemVersion>1.0</urn3:codeSystemVersion>
                         <urn3:displayName>nameCode</urn3:displayName>
                         <urn3:originalText>nameCode</urn3:originalText>
                      </urn3:nameType>
                      <urn3:secondNameOrInitials>S</urn3:secondNameOrInitials>
                      <urn3:fullName>Kasrl S. Skagerberg</urn3:fullName>
                   </urn3:personName>
                   <urn3:userName>kskagerberg</urn3:userName>
                   <urn3:org>
                      <urn3:description>${#Project#LocalHCDescription}</urn3:description>
                      <urn3:homeCommunityId>${#Project#LocalHCID}</urn3:homeCommunityId>
                      <urn3:name>${#Project#LocalHCDescription}</urn3:name>
                   </urn3:org>
                   <urn3:roleCoded>
                      <urn3:code>307969004</urn3:code>
                      <urn3:codeSystem>2.16.840.1.113883.6.96</urn3:codeSystem>
                      <urn3:codeSystemName>SNOMED_CT</urn3:codeSystemName>
                      <urn3:codeSystemVersion>1.0</urn3:codeSystemVersion>
                      <urn3:displayName>Public Health</urn3:displayName>
                      <urn3:originalText>Public Health</urn3:originalText>
                   </urn3:roleCoded>
                </urn3:userInfo>
                <urn3:authorized xmlns:urn1="urn:gov:hhs:fha:nhinc:common:nhinccommon">true</urn3:authorized>
                <urn3:purposeOfDisclosureCoded xmlns:urn1="urn:gov:hhs:fha:nhinc:common:nhinccommon">
                   <urn3:code>PUBLICHEALTH</urn3:code>
                   <urn3:codeSystem>2.16.840.1.113883.3.18.7.1</urn3:codeSystem>
                   <urn3:codeSystemName>nhin-purpose</urn3:codeSystemName>
                   <urn3:codeSystemVersion>1.0</urn3:codeSystemVersion>
                   <urn3:displayName>Use or disclosure of Psychotherapy Notes</urn3:displayName>
                   <urn3:originalText>Use or disclosure of Psychotherapy Notes</urn3:originalText>
                </urn3:purposeOfDisclosureCoded>
                <urn3:samlAuthnStatement xmlns:urn1="urn:gov:hhs:fha:nhinc:common:nhinccommon">
                   <urn3:authInstant>2009-04-16T13:15:39Z</urn3:authInstant>
                   <urn3:sessionIndex>987</urn3:sessionIndex>
                   <urn3:authContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:X509</urn3:authContextClassRef>
                   <urn3:subjectLocalityAddress>158.147.185.168</urn3:subjectLocalityAddress>
                   <urn3:subjectLocalityDNSName>cs.myharris.net</urn3:subjectLocalityDNSName>
                </urn3:samlAuthnStatement>
             <urn3:samlAuthzDecisionStatement xmlns:urn1="urn:gov:hhs:fha:nhinc:common:nhinccommon">
                   <urn3:decision>Permit</urn3:decision>
                   <urn3:resource>https://158.147.185.168:8181/SamlReceiveService/SamlProcessWS</urn3:resource>
                   <urn3:action>TestSaml</urn3:action>
                   <urn3:evidence>
                      <urn3:assertion>
                         <urn3:id>40df7c0a-ff3e-4b26-baeb-f2910f6d05a9</urn3:id>
                         <urn3:issueInstant>2009-04-16T13:10:39.093Z</urn3:issueInstant>
                         <urn3:version>2.0</urn3:version>
                         <urn3:issuerFormat>urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName</urn3:issuerFormat>
                         <urn3:issuer>CN=SAML User,OU=Harris,O=HITS,L=Melbourne,ST=FL,C=US</urn3:issuer>
                         <urn3:conditions>
                            <urn3:notBefore>2009-04-16T13:10:39.093Z</urn3:notBefore>
                            <urn3:notOnOrAfter>2009-12-31T12:00:00.000Z</urn3:notOnOrAfter>
                         </urn3:conditions>
                         <urn3:accessConsentPolicy>urn:oid:1.2.3.4</urn3:accessConsentPolicy>
                         <urn3:instanceAccessConsentPolicy>urn:oid:1.2.3.4.123456789</urn3:instanceAccessConsentPolicy>
                      </urn3:assertion>
                   </urn3:evidence>
                </urn3:samlAuthzDecisionStatement>
             </urn:assertion>
             <urn:NhinTargetCommunities>
                <urn3:nhinTargetCommunity>
                   <urn3:homeCommunity>
                      <urn3:description>${#Project#RemoteHCDescription}</urn3:description>
                      <urn3:homeCommunityId>${#Project#RemoteHCID}</urn3:homeCommunityId>
                      <urn3:name>${#Project#RemoteHCDescription}</urn3:name>
                   </urn3:homeCommunity>
                </urn3:nhinTargetCommunity>
             </urn:NhinTargetCommunities>
          </urn:RespondingGateway_CrossGatewayQueryRequest>';
    $opts = array(
        'http'=>array('user_agent' => 'PHPSoapClient'),
        'ssl' => array('ciphers' => 'SHA1'),
    );
    $context = stream_context_create($opts);
    $options = array(
                    'verifypeer'          => true,
                    'verifyhost'          => true,
                    'soap_version'        => SOAP_1_2,
                    'trace'               => 0,
                    'exceptions'          => 0,
                    'connection_timeout'  => 18000,
                    'stream_context'      => $context,
                    'Content-length'      => strlen($body),
                    'Content-type'        => 'application/xml',
                    ); 
    ini_set("soap.wsdl_cache_enabled", "1");
    //Adapter/DocumentQuery/A_0/AdapterDocQueryUnsecured?wsdl
    $client = new HackySoapClient("http://117.239.157.99:8080/Gateway/DocumentQuery/2_0/EntityService/EntityDocQueryUnsecured?wsdl", $options);
    //$client = new HackySoapClient("http://192.168.1.7:8080/Gateway/PatientDiscovery/1_0/EntityPatientDiscovery?wsdl", $options);
    $finalRequestHeader = "";
    $strHeaderComponent_Session     = $finalRequestHeader;
    $objVar_Session_Inside          = new \SoapVar($strHeaderComponent_Session, XSD_ANYXML, null, null, null);
    $objHeader_Session_Outside      = new \SoapHeader('http://www.w3.org/2003/05/soap-envelope', 'SessionHeader', $objVar_Session_Inside);
    $client->__setSoapHeaders(array($objHeader_Session_Outside));
    try{
    
       $xmlBodyOut = new \SoapVar($body, XSD_ANYXML, null, null, null);
       $result = $client->RespondingGateway_CrossGatewayQuery($xmlBodyOut);
       //$result = $client->RespondingGateway_PRPA_IN201305UV02($xmlBodyOut);
    }
    catch(Exception $e){
        echo "Exception<br><br><pre>";
        //echo $client->__getLastRequest();
        echo "<br><br>";
        var_dump($e);
    }
    var_dump($result);

Re: Soap Client is not working after editing the request hea

Posted: Tue Feb 14, 2017 11:19 pm
by Christopher
Why are you doing this?

Code: Select all

              $request = str_replace( '<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="urn:hl7-org:v3">', '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:urn="urn:gov:hhs:fha:nhinc:common:nhinccommonentity" xmlns:urn1="urn:oasis:names:tc:ebxml-regrep:xsd:query:3.0" xmlns:urn2="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0" xmlns:urn3="urn:gov:hhs:fha:nhinc:common:nhinccommon">', $request );