Jump to content

kellendil

New Members
  • Posts

    6
  • Joined

  • Last visited

Everything posted by kellendil

  1. Thanks for the reply, I'll try it out The reason for parsing the response is simple, I don't have access to the stream, only the generated xml-files Stupid, I know.
  2. Hi! I'm having trouble accessing data with simpleXML_load_file I have a working script that loads an XML-file and outputs in a proprietary format that I've written, but for some reason I can't get it to work with this second set of XML-files. Loading the file seems to work fine. I load the file into a variable, and can print the contents of the file using echo $xml -> asXML(); However, when I try to access a single node using: echo $xml->{'SOAP-ENV:Envelope'}->{'SOAP-ENV:Body'}->Order->OrderHeader->OrderNumber->BuyerOrderNumber; I get the following error: Notice: Trying to get property of non-object in C:\www\convert_uio.php on line 28 XML-file looks as follows: <?xml version="1.0" encoding="utf-8"?> <SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <SOAP-ENV:Header> <nseps:endpoints SOAP-ENV:mustUnderstand="true" xmlns:nseps="urn:schemas-IBX:/docs/endpoint.nsendpoint"> <nseps:to> <nseps:address>8b51fc8c-7aba-1000-bbbe-c0a878330001</nseps:address> </nseps:to> <nseps:from> <nseps:address>1b0ad9d6-7a05-1000-a43c-c0a878330001</nseps:address> </nseps:from> </nseps:endpoints> <nsprop:properties SOAP-ENV:mustUnderstand="true" xmlns:nsprop="urn:schemas-IBX:/docs/property.nsproperty"> <nsprop:identity>fb1797dbb1f14a179482b1bb53bc7c14</nsprop:identity> <nsprop:sentAt>2014-09-02T00:00:00+01:00</nsprop:sentAt> <nsprop:topic>Order</nsprop:topic> </nsprop:properties> </SOAP-ENV:Header> <SOAP-ENV:Body> <Order xmlns="rrn:org.xcbl:schemas/xcbl/v3_5/xcbl35.xsd"> <OrderHeader> <OrderNumber> <BuyerOrderNumber>E14124673</BuyerOrderNumber> </OrderNumber> <OrderIssueDate>20140902T00:00:00+01:00</OrderIssueDate> <OrderReferences> <AccountCode> <Reference> <RefNum>no_unoslo</RefNum> </Reference> </AccountCode> </OrderReferences> <Purpose> <PurposeCoded>Original</PurposeCoded> </Purpose> <RequestedResponse> <RequestedResponseCoded>NoAcknowledgementNeeded</RequestedResponseCoded> </RequestedResponse> <OrderType> <OrderTypeCoded>PurchaseOrder</OrderTypeCoded> </OrderType> <OrderCurrency> <Currency> <CurrencyCoded>NOK</CurrencyCoded> </Currency> </OrderCurrency> <OrderLanguage> <Language LanguageDependent="false"> <LanguageCoded>no</LanguageCoded> </Language> </OrderLanguage> <OrderDates> <RequestedDeliverByDate>20140904T00:00:00+01:00</RequestedDeliverByDate> </OrderDates> <OrderParty> <BuyerParty> <Party> <PartyID> <Identifier> <Agency> <AgencyCoded>AssignedByBuyerOrBuyersAgent</AgencyCoded> </Agency> <Ident>no_uio</Ident> </Identifier> </PartyID> <NameAddress> <Name1>xxxxxxxxxxxxx</Name1> <Name2>xxxxxxxxxxxxx</Name2> <POBox>xxxxx</POBox> <PostalCode>NO-0316</PostalCode> <City>Oslo</City> <Country> <CountryCoded>NO</CountryCoded> </Country> </NameAddress> <OrderContact> <Contact> <ContactName>Some Name</ContactName> <ContactFunction> <ContactFunctionCoded>PurchasingContact</ContactFunctionCoded> </ContactFunction> <ListOfContactNumber> <ContactNumber> <ContactNumberValue>email@email.no</ContactNumberValue> <ContactNumberTypeCoded>EmailAddress</ContactNumberTypeCoded> </ContactNumber> <ContactNumber> <ContactNumberValue>+4700000000</ContactNumberValue> <ContactNumberTypeCoded>TelephoneNumber</ContactNumberTypeCoded> </ContactNumber> </ListOfContactNumber> </Contact> </OrderContact> </Party> </BuyerParty> <BuyerTaxInformation> <PartyTaxInformation> <TaxIdentifier> <Identifier> <Agency> <AgencyCoded>Other</AgencyCoded> <AgencyCodedOther>VAT Number</AgencyCodedOther> </Agency> <Ident>00000000</Ident> </Identifier> </TaxIdentifier> </PartyTaxInformation> </BuyerTaxInformation> <SellerParty> <Party> <PartyID> <Identifier> <Agency> <AgencyCoded>AssignedByBuyerOrBuyersAgent</AgencyCoded> </Agency> <Ident>8b51fc8c-7aba-1000-bbbe-c0a878330001</Ident> </Identifier> </PartyID> <NameAddress> <Name1>Name 2</Name1> <Street>Adress</Street> <PostalCode> 0314</PostalCode> <City>OSLO</City> <Country> <CountryCoded>NO</CountryCoded> </Country> </NameAddress> <OrderContact> <Contact> <ContactName>N/A</ContactName> <ListOfContactNumber> <ContactNumber> <ContactNumberValue>email</ContactNumberValue> <ContactNumberTypeCoded>EmailAddress</ContactNumberTypeCoded> </ContactNumber> <ContactNumber> <ContactNumberValue>47 0000000</ContactNumberValue> <ContactNumberTypeCoded>FaxNumber</ContactNumberTypeCoded> </ContactNumber> </ListOfContactNumber> </Contact> </OrderContact> </Party> </SellerParty> <ShipToParty> <Party> <PartyID> <Identifier> <Agency> <AgencyCoded>AssignedByBuyerOrBuyersAgent</AgencyCoded> </Agency> <Ident /> </Identifier> </PartyID> <NameAddress> <Name1>Name</Name1> <Name2>Name2 </Name2> <Street>Adress</Street> <StreetSupplement1>0318 Oslo</StreetSupplement1> <PostalCode>NO-0562</PostalCode> <City>OSLO</City> <Country> <CountryCoded>NO</CountryCoded> </Country> </NameAddress> <OrderContact> <Contact> <ContactName>Name</ContactName> <ContactFunction> <ContactFunctionCoded>PurchasingContact</ContactFunctionCoded> </ContactFunction> <ListOfContactNumber> <ContactNumber> <ContactNumberValue>emamil</ContactNumberValue> <ContactNumberTypeCoded>EmailAddress</ContactNumberTypeCoded> </ContactNumber> <ContactNumber> <ContactNumberValue>+470000000</ContactNumberValue> <ContactNumberTypeCoded>TelephoneNumber</ContactNumberTypeCoded> </ContactNumber> </ListOfContactNumber> </Contact> </OrderContact> <ReceivingContact> <Contact> <ContactName>Name</ContactName> <ContactFunction> <ContactFunctionCoded>PurchasingContact</ContactFunctionCoded> </ContactFunction> <ListOfContactNumber> <ContactNumber> <ContactNumberValue>email</ContactNumberValue> <ContactNumberTypeCoded>EmailAddress</ContactNumberTypeCoded> </ContactNumber> <ContactNumber> <ContactNumberValue>+4700000000</ContactNumberValue> <ContactNumberTypeCoded>TelephoneNumber</ContactNumberTypeCoded> </ContactNumber> </ListOfContactNumber> </Contact> </ReceivingContact> </Party> </ShipToParty> <BillToParty> <Party> <PartyID> <Identifier> <Agency> <AgencyCoded>AssignedByBuyerOrBuyersAgent</AgencyCoded> </Agency> <Ident>no_uio</Ident> </Identifier> </PartyID> <NameAddress> <Name1>Name</Name1> <Name2>Adress</Name2> <POBox>adress2</POBox> <PostalCode>NO-0316</PostalCode> <City>Oslo</City> <County /> <District>9908:971035854</District> <Country> <CountryCoded>NO</CountryCoded> </Country> </NameAddress> <OrderContact> <Contact> <ContactName>Name</ContactName> <ContactFunction> <ContactFunctionCoded>PurchasingContact</ContactFunctionCoded> </ContactFunction> <ListOfContactNumber> <ContactNumber> <ContactNumberValue>email</ContactNumberValue> <ContactNumberTypeCoded>EmailAddress</ContactNumberTypeCoded> </ContactNumber> <ContactNumber> <ContactNumberValue>+470000000</ContactNumberValue> <ContactNumberTypeCoded>TelephoneNumber</ContactNumberTypeCoded> </ContactNumber> </ListOfContactNumber> </Contact> </OrderContact> </Party> </BillToParty> </OrderParty> <OrderTermsOfDelivery> <TermsOfDelivery> <TermsOfDeliveryFunctionCoded>Other</TermsOfDeliveryFunctionCoded> <TermsOfDeliveryFunctionCodedOther>Other</TermsOfDeliveryFunctionCodedOther> <TransportTermsCoded>Other</TransportTermsCoded> <TransportTermsCodedOther>DDP</TransportTermsCodedOther> <ShipmentMethodOfPaymentCoded>Other</ShipmentMethodOfPaymentCoded> <ShipmentMethodOfPaymentCodedOther>Other</ShipmentMethodOfPaymentCodedOther> <TransportDescription /> </TermsOfDelivery> </OrderTermsOfDelivery> <OrderHeaderNote /> </OrderHeader> <OrderDetail> <ListOfItemDetail> <ItemDetail> <BaseItemDetail> <LineItemNum> <BuyerLineItemNum>1</BuyerLineItemNum> </LineItemNum> <LineItemType> <LineItemTypeCoded>Item</LineItemTypeCoded> </LineItemType> <ItemIdentifiers> <PartNumbers> <SellerPartNumber> <PartNum> <PartID>1000000000001</PartID> </PartNum> </SellerPartNumber> <ManufacturerPartNumber> <PartID /> </ManufacturerPartNumber> </PartNumbers> <ItemDescription>Normal frakt, pris 20 NOK</ItemDescription> </ItemIdentifiers> <TotalQuantity> <Quantity> <QuantityValue>1</QuantityValue> <UnitOfMeasurement> <UOMCoded>EA</UOMCoded> </UnitOfMeasurement> </Quantity> </TotalQuantity> <OffCatalogFlag>false</OffCatalogFlag> </BaseItemDetail> <PricingDetail> <ListOfPrice> <Price> <UnitPrice> <UnitPriceValue>20</UnitPriceValue> <Currency> <CurrencyCoded>NOK</CurrencyCoded> </Currency> <UnitOfMeasurement> <UOMCoded>EA</UOMCoded> </UnitOfMeasurement> </UnitPrice> <PriceBasisQuantity> <Quantity> <QuantityValue>1</QuantityValue> <UnitOfMeasurement> <UOMCoded>EA</UOMCoded> </UnitOfMeasurement> </Quantity> </PriceBasisQuantity> </Price> </ListOfPrice> <Tax> <TaxFunctionQualifierCoded>Tax</TaxFunctionQualifierCoded> <TaxCategoryCoded>StandardRate</TaxCategoryCoded> <TaxTypeCoded>ValueAddedTax</TaxTypeCoded> <TaxPercent>.00</TaxPercent> <TaxableAmount>20.00</TaxableAmount> <TaxAmount>.00</TaxAmount> </Tax> <TotalValue> <MonetaryValue> <MonetaryAmount>20.00</MonetaryAmount> </MonetaryValue> </TotalValue> </PricingDetail> <DeliveryDetail> <ListOfScheduleLine> <ScheduleLine> <Quantity> <QuantityValue>1</QuantityValue> <UnitOfMeasurement> <UOMCoded>EA</UOMCoded> </UnitOfMeasurement> </Quantity> <RequestedDeliveryDate>20140904T00:00:00+01:00</RequestedDeliveryDate> </ScheduleLine> </ListOfScheduleLine> </DeliveryDetail> </ItemDetail> <ItemDetail> <BaseItemDetail> <LineItemNum> <BuyerLineItemNum>2</BuyerLineItemNum> </LineItemNum> <LineItemType> <LineItemTypeCoded>Item</LineItemTypeCoded> </LineItemType> <ItemIdentifiers> <PartNumbers> <SellerPartNumber> <PartNum> <PartID>9788258312007</PartID> </PartNum> </SellerPartNumber> <ManufacturerPartNumber> <PartID /> </ManufacturerPartNumber> </PartNumbers> <ItemDescription>Hovedtariffavtalen i staten 1. mai 2014 - 30. april 2016 (p.100kr)</ItemDescription> </ItemIdentifiers> <TotalQuantity> <Quantity> <QuantityValue>2</QuantityValue> <UnitOfMeasurement> <UOMCoded>EA</UOMCoded> </UnitOfMeasurement> </Quantity> </TotalQuantity> <OffCatalogFlag>false</OffCatalogFlag> </BaseItemDetail> <PricingDetail> <ListOfPrice> <Price> <UnitPrice> <UnitPriceValue>100</UnitPriceValue> <Currency> <CurrencyCoded>NOK</CurrencyCoded> </Currency> <UnitOfMeasurement> <UOMCoded>EA</UOMCoded> </UnitOfMeasurement> </UnitPrice> <PriceBasisQuantity> <Quantity> <QuantityValue>1</QuantityValue> <UnitOfMeasurement> <UOMCoded>EA</UOMCoded> </UnitOfMeasurement> </Quantity> </PriceBasisQuantity> </Price> </ListOfPrice> <Tax> <TaxFunctionQualifierCoded>Tax</TaxFunctionQualifierCoded> <TaxCategoryCoded>StandardRate</TaxCategoryCoded> <TaxTypeCoded>ValueAddedTax</TaxTypeCoded> <TaxPercent>.00</TaxPercent> <TaxableAmount>100.00</TaxableAmount> <TaxAmount>.00</TaxAmount> </Tax> <TotalValue> <MonetaryValue> <MonetaryAmount>200.00</MonetaryAmount> </MonetaryValue> </TotalValue> </PricingDetail> <DeliveryDetail> <ListOfScheduleLine> <ScheduleLine> <Quantity> <QuantityValue>2</QuantityValue> <UnitOfMeasurement> <UOMCoded>EA</UOMCoded> </UnitOfMeasurement> </Quantity> <RequestedDeliveryDate>20140904T00:00:00+01:00</RequestedDeliveryDate> </ScheduleLine> </ListOfScheduleLine> </DeliveryDetail> </ItemDetail> </ListOfItemDetail> </OrderDetail> <OrderSummary> <NumberOfLines>2</NumberOfLines> <TotalTax> <MonetaryValue> <MonetaryAmount>.00</MonetaryAmount> </MonetaryValue> </TotalTax> <TotalAmount> <MonetaryValue> <MonetaryAmount>220.00</MonetaryAmount> <Currency> <CurrencyCoded>NOK</CurrencyCoded> </Currency> </MonetaryValue> </TotalAmount> </OrderSummary> </Order> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
  3. Thanks alot, lets see if I understand it all :> [code]require_once('dbConfiguration.inc.php');[/code] ok, this is where i put my configuration, in your example it would look something like this? [code] <?php //configuration file for databaseconnection. $dbconfig['dbHost'] = 'databasehost'; $dbconfig['dbUser'] = 'databaseusername'; $dbconfig['dbPassword'] = 'databasepass';  ?> [/code] The rest of the code is pretty self explanatory, so I won't ask stupid questions about that :] You are absolutely correct about seperating the errorhandling and configuration, I should have though about that myself, but as I mentioned, I'm fairly new to the OO approach :) Thanks again for your help :) -Kellendil
  4. As I said, it was a feeble attempt, I know that it isn't correct, which is why I'm asking for help :] [quote]Really, the class itself should take care of instigating connections too, you shouldn't need to specifically call a method to open a connection.[/quote] This is what I've read elsewhere as well, but I haven't been able to find a good example, so I don't really understand how I do it. [quote]Basically, all the code in your example isn't really needed (or wanted) within a database class.[/quote] How does one close a database connection then (manually, I know that it isn't usually necessary) -Kellendil
  5. I'm trying to make a very simple DB class, but haven't quite gotten the hang for using classes, to put it mildly. Anyway, I'm making this class, with just a few functions, mainly to make, and use a class. Expanding on it later when I have a working one, should not be a big problem. The class is, as mentioned, a database class, I want it to have the following 3 functions: -Open a connection, with variables listed within the class -Execute a query -Close connection. My own feeble attempt: [code] class database { var $dbhost = 'serveradress'; var $dbusername = 'username'; var $dbpasswd = 'password';  var $database_name = 'dbname'; //open connection. function sqlOpen($dbhost,$dbusername,$dbpasswd) { $connection = mysql_connect("$dbhost","$dbusername","$dbpasswd") or die ("Couldn't connect to server."); $db = mysql_select_db("$database_name", $connection) or die("Couldn't select database."); return $db; } //close connection. function sqlClose($connection) { mysql_close($connection); } }[/code] As you can see, I haven't included any code for executing a query, but I don't think that will pose a huge problem. Anyway, if someone could help me out or point me in the correct direction, and perhaps give me an example of how a class like this would be used (spesifically the opening of a database connection) I would be very very grateful :) -Kellendil
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.