Solved

cxml request using php curl

Posted on 2014-01-07
9
911 Views
Last Modified: 2014-02-20
I am working with an ERP system that wants to use a cxml punchout.

I am using a CURL script but I am not recieving any response.

The code I am using is:

$data = 
array( "Credential" => array("Identity"=>"xxxxxx"),array("Secret"=>"xxxxxx")); 
                                                               
$data_string = json_encode($data);                                                                                   
$ch = curl_init('https://xxxxxxxx/12456');

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);                                                                  
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
curl_setopt($ch, CURLOPT_HTTPHEADER, array(     
	'domain: DUNS',                                                                 
	'Content-Type: text/xml',
	'Content-Type: application/xml ',                                                                          
    'Content-Length: ' . strlen($data_string))                                                                       
);   
                                                                                                               

$result = curl_exec($ch);

print_r($result);

Open in new window


I am receiving the following error:


Error Processing Request. ErrorMessage: 'Enveloping Error' TrackID: '371557229' Date: '2014.01.07 14:11:12 UTC'


Not really sure where to start or how to build the request...

Thanks
0
Comment
Question by:bradley525
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 39762098
This does not look like an error.  It looks like a valid response from the ERP resource.  Can you show us a link to the examples of how to use the ERP system?
0
 

Author Comment

by:bradley525
ID: 39762140
Hi Ray,

Right now I am just trying to get a response. This is actually just a file and not part of a system.  Above is everything I have..Are you looking for more documentation?
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 39762253
You are getting a response.  Response is a term of art in API processing.  But that said, it's probably not the response you want.  The cURL part is working correctly.  The script has connected successfully to the ERP resource, and the resource said, "Error Processing Request..."  

That's why we need to see the documentation that tells how to present the credentials.  It may be very simple, but until we know what the ERP system expects, we would just be guessing.

Here is one guess:

$data = 
array( "Credential" => array("Identity"=>"xxxxxx","Secret"=>"xxxxxx")); 

Open in new window

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:bradley525
ID: 39774766
Sorry it took me so long to respond I wanted to get some example documentation. Here is the xml that needs to be sent to get the vaild response. I am not sure how to put this into a CURL format..Any help would be greatly appreciated.

Thanks

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE cXML SYSTEM "http://xml.cXML.org/schemas/cXML/1.2.011/cXML.dtd">
<cXML timestamp="2013-11-14T12:33:56 -05:00" payloadID="1384450436804.960375321871699717@" version="1.2.011">
   <Header>
      <From>
         <Credential domain="NetworkID">
            <Identity>Company Name</Identity>
         </Credential>
      </From>
      <To>
         <Credential domain="DUNS">
            <Identity>SigmaAldrich</Identity>
         </Credential>
      </To>
      <Sender>
         <Credential domain="NetworkID">
            <Identity>Sender ID</Identity>
            <SharedSecret>SIG07ALD</SharedSecret>
         </Credential>
         <UserAgent>BioProcure</UserAgent>
      </Sender>
   </Header>
   <Request deploymentMode="production">
      <OrderRequest>
         <OrderRequestHeader orderDate="2013-11-14T12:33:56-0500" orderID="PO Value" type="new">
            <Total>
               <Money currency="USD">241.50</Money>
            </Total>
            <ShipTo>
               <Address isoCountryCode="US" addressID="Ship to ID">
                  <Name xml:lang="en-US">Company Name/Name>
                  <PostalAddress name="default">
                     <DeliverTo>Attn Line</DeliverTo>
                     <DeliverTo>Bldg and Room </DeliverTo>
                     <Street>Street Address</Street>
                     <City>City</City>
                     <State>MO</State>
                     <PostalCode>Zip Code</PostalCode>
                     <Country isoCountryCode="US">US</Country>
                  </PostalAddress>
                  <Email name="default">a@b.com</Email>
                  <Phone name="work">
                     <TelephoneNumber>
                        <CountryCode isoCountryCode="US">1</CountryCode>
                        <AreaOrCityCode>555</AreaOrCityCode>
                        <Number>5555555</Number>
                     </TelephoneNumber>
                  </Phone>
                  <Fax name="">
                     <TelephoneNumber>
                        <CountryCode isoCountryCode="" />
                        <AreaOrCityCode />
                        <Number />
                     </TelephoneNumber>
                  </Fax>
               </Address>
            </ShipTo>
            <BillTo>
               <Address isoCountryCode="" addressID="ACCOUNTS PAYABLE">
                  <Name xml:lang="en-US">Company Name</Name>
                  <PostalAddress name="default">
                     <DeliverTo>Accounts Payable</DeliverTo>
                     <Street>Street</Street>
                     <City>City</City>
                     <State>MO</State>
                     <PostalCode>Zip Code</PostalCode>
                     <Country isoCountryCode="US">US</Country>
                  </PostalAddress>
                  <Email name="default">a@b.com</Email>
                  <Phone name="work">
                     <TelephoneNumber>
                        <CountryCode isoCountryCode="US">1</CountryCode>
                        <AreaOrCityCode>555</AreaOrCityCode>
                        <Number>5555555</Number>
                     </TelephoneNumber>
                  </Phone>
                  <Fax name="">
                     <TelephoneNumber>
                        <CountryCode isoCountryCode="" />
                        <AreaOrCityCode />
                        <Number />
                     </TelephoneNumber>
                  </Fax>
               </Address>
            </BillTo>
            <Contact role="user">
               <Name xml:lang="en-US">enduser name</Name>
               <PostalAddress name="">
                  <Street />
                  <City />
                  <Country isoCountryCode="" />
               </PostalAddress>
               <Email name="">a@b.com</Email>
               <Phone name="">
                  <TelephoneNumber>
                     <CountryCode isoCountryCode="" />
                     <AreaOrCityCode />
                     <Number />
                  </TelephoneNumber>
               </Phone>
            </Contact>
<Shipping>
               <Money currency=""/>
               <Description xml:lang="en-US">FEDEX STANDARD OVERNIGHT - 3:00pm NEXT BUSINESS DAY</Description>
            </Shipping>
            <Comments />
         </OrderRequestHeader>
         <ItemOut quantity="1" lineNumber="1">
            <ItemID>
               <SupplierPartID>D1523-10MG</SupplierPartID>
               <SupplierPartAuxiliaryID>CartId`78086342</SupplierPartAuxiliaryID>
            </ItemID>
            <ItemDetail>
               <UnitPrice>
                  <Money currency="USD">241.50</Money>
               </UnitPrice>
               <Description xml:lang="en-US">N,N'-DIACETYLCHITOBIOSE, N,N'-DIACETYLCHITOBIOSE</Description>
               <UnitOfMeasure>EA</UnitOfMeasure>
               <Classification domain="UNSPSC">12352201</Classification>
               <ManufacturerPartID />
               <ManufacturerName />
            </ItemDetail>
         </ItemOut>
      </OrderRequest>
   </Request>
</cXML>

Open in new window

0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 39774848
This appears to have an error in line 31.  Any chance we can see the documentation that describes the information you need to send?
0
 

Author Comment

by:bradley525
ID: 39774861
They did not provide any documentation..Just example xml..What is the error? is is  the

"xml:" ?
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 39774867
Line 31 says this:
<Name xml:lang="en-US">Company Name/Name>

I believe that it should say this:
<Name xml:lang="en-US">Company Name</Name>

In the original question we were looking at JSON-encoded data.  This was put into the CURLOPT_POSTFIELDS.  Maybe this XML string is supposed to go there?  I don't know and could not guess unless the provider is able to give us some documentation that says what it expects to receive.
0
 

Accepted Solution

by:
bradley525 earned 0 total points
ID: 39805324
I spoke with the company who provided the CXML helped us to get this to work. She had to provide different credentials and and test url. Unfortunately there was nothing I could have done with this code.

Thank you all for the help anyways.
0
 

Author Closing Comment

by:bradley525
ID: 39872873
The cXML request is unique to the customers system. They had to provide unique cridentials and everything worked..
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question