Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

wsse:InvalidSecurity

Former Member
0 Likes
1,908
  • SAP Managed Tags

Hi there,

I have tried to implement a small PHP script for submitting ideas to xPD 2.0. First phase is successful (idea is submitted and guid retrieved). But when I try to upload an attachent using different webservice I get this error message:

wsse:InvalidSecurity. 00E000C4EA35007A0000035700001077000412CCC9797F64 : WS Security can only be applied on a SOAP document.

Any ideas why my second soap call is failing?

Here are both scripts for you:

submit.php (this works)

[code]

<?php

$title = $_POST['title'];

$description = $_POST['description'];

$source = $_POST['source'];

$client = new SoapClient('our_server/WSxPDService/WSxPDServiceConfig?wsdl',

array('login' => "xxx", 'password' => "xxx", 'style' => SOAP_DOCUMENT));

$header = array("description" => $description,

"owner" => "xxx",

"title" => $title,

"guid" => "",

"source" => $source,

"author" => "xxx",

"protectionLevel" => "Normal",

"relatedInsights" => "",

"relatedFacts" => ""

);

try {

$result = $client->createIdea(array("header" => $header));

} catch (SoapFault $exception) {

die("<b>Idea submission failed!</b><br>" . $exception->content);

}

$guid = $result->Response;

include("attachment.inc");

?>

[/code]

submitAttachment.php (this does not work)

[code]

<?php

$guid = $_POST['guid'];

$name = $_POST['name'];

$attachment = $_FILES['attachment']['tmp_name'];

$contents = file_get_contents($attachment);

$client = new SoapClient('our_server/WSxPDExternalIdeaAttachment/EIAttachmentConfig?wsdl ', array('login' => "xxx", 'password' => "xxx"));

try {

$result = @$client->addIdeaAttachment( $guid, $name, $contents );

} catch (SoapFault $exception) {

die("<b>Attachment upload failed!</b><br>" . $exception->faultcode . ". " . $exception->faultstring . "<br><b>" . var_dump($exception));

}

Header("Location: addAttachments.php?guid=$guid");

exit;

?>

[/code]

Br,

Johannes

9 REPLIES 9
Read only

gregorw
SAP Mentor
SAP Mentor
0 Likes
1,621
  • SAP Managed Tags

Hi Johannes,

could you tell us a bit more about your system landscape? What exct version of PHP and WebAS are you running on including Service Packs.

Regards

Gregor

Read only

Former Member
0 Likes
1,621
  • SAP Managed Tags

Hi Gregor,

PHP version is 5.1.2.

We are running on Web AS Java 7.00 SP 5 (Ramp-Up product)with Portal 7.00 and xPD 2.0 SP1.

First I thought this could be some kind of authrorization thing but those settings should be similar to the service which is working.

Here's the soap request which is sent to the webservice.

<?xml version="1.0" encoding="UTF-8"?>

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">

<SOAP-ENV:Body>

<SOAP-ENV:addIdeaAttachment>

<ideaGuid>d0cc4480-da69-11da-be20-00e000c4ea35</ideaGuid>

<name>debug_settings.jpg</name>

<content>/9j/4AAQ... //skip rest of content // ...AL1FFFAH/2Q==</content>

</SOAP-ENV:addIdeaAttachment>

</SOAP-ENV:Body>

</SOAP-ENV:Envelope>

Br,

Johannes

Read only

Former Member
0 Likes
1,621
  • SAP Managed Tags

hi,

the WSDL would be helpful as well. does the WSDL define style as 'document'?

i suppose there is a style problem. maybe the WSDL says rpc, or it's just the style = SOAP_DOCUMENT declararion missing in the constructor of your client.

regards,

anton

Read only

Former Member
0 Likes
1,621
  • SAP Managed Tags

Hi Anton,

There's only one style called 'mime' available. Then there's standard and SAP version of that. I have tried both.

I tried to change the constructor like this (no success):

[code]

$client = new SoapClient('http://xxxx:50200/WSxPDExternalIdeaAttachment/EIAttachmentConfig?wsdl',

array('login' => "xxx", 'password' => "xxx", "style" => 'mime'));

[/code]

Here's the standard wsdl for you:

<?xml version="1.0" encoding="utf-8"?>

<!-- Generated by WSDLDefinitionsParser --><wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="WSxPDExternalIdeaAttachmentWsd" targetNamespace="urn:WSxPDExternalIdeaAttachmentWsd" xmlns:bns0="urn:WSxPDExternalIdeaAttachmentWsd/EIAttachmentConfig/mime" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">

<wsdl:import location="./bindings/EIAttachmentConfig_mime.wsdl" namespace="urn:WSxPDExternalIdeaAttachmentWsd/EIAttachmentConfig/mime"/>

<wsdl:service name="WSxPDExternalIdeaAttachment">

<wsdl:port name="EIAttachmentConfigPort_Mime" binding="bns0:EIAttachmentConfigBinding">

<soap:address location="http://xxxx:50200/WSxPDExternalIdeaAttachment/EIAttachmentConfig?style=mime"/>

</wsdl:port>

</wsdl:service>

</wsdl:definitions>

Bindings:

<?xml version="1.0" encoding="utf-8"?>

<!-- Generated by WSDLDefinitionsParser --><wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="urn:WSxPDExternalIdeaAttachmentWsd/EIAttachmentConfig/mime" xmlns:prt0="urn:WSxPDExternalIdeaAttachmentWsd/WSxPDExternalIdeaAttachmentVi/rpc_enc" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/">

<wsdl:import location="../porttypes/EIAttachmentConfig_WSxPDExternalIdeaAttachmentVi_rpc_enc.wsdl" namespace="urn:WSxPDExternalIdeaAttachmentWsd/WSxPDExternalIdeaAttachmentVi/rpc_enc"/>

<wsdl:binding name="EIAttachmentConfigBinding" type="prt0:WSxPDExternalIdeaAttachmentVi_Rpc_enc">

<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>

<wsdl:operation name="addIdeaAttachment">

<soap:operation soapAction=""/>

<wsdl:input>

<mime:multipartRelated>

<mime:part>

<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:WSxPDExternalIdeaAttachmentVi"/>

</mime:part>

<mime:part>

<mime:content part="content" type="application/octetstream"/>

</mime:part>

</mime:multipartRelated>

</wsdl:input>

<wsdl:output>

<mime:multipartRelated>

<mime:part>

<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:WSxPDExternalIdeaAttachmentVi"/>

</mime:part>

</mime:multipartRelated>

</wsdl:output>

<wsdl:fault name="com.sap.xapps.xpd.webservices.exception.BOCreateException">

<soap:fault use="encoded" name="com.sap.xapps.xpd.webservices.exception.BOCreateException" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>

</wsdl:fault>

</wsdl:operation>

<wsdl:operation name="getIdeaCategories">

<soap:operation soapAction=""/>

<wsdl:input>

<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:WSxPDExternalIdeaAttachmentVi"/>

</wsdl:input>

<wsdl:output>

<mime:multipartRelated>

<mime:part>

<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:WSxPDExternalIdeaAttachmentVi"/>

</mime:part>

</mime:multipartRelated>

</wsdl:output>

</wsdl:operation>

<wsdl:operation name="submitIdea">

<soap:operation soapAction=""/>

<wsdl:input>

<mime:multipartRelated>

<mime:part>

<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:WSxPDExternalIdeaAttachmentVi"/>

</mime:part>

</mime:multipartRelated>

</wsdl:input>

<wsdl:output>

<mime:multipartRelated>

<mime:part>

<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:WSxPDExternalIdeaAttachmentVi"/>

</mime:part>

</mime:multipartRelated>

</wsdl:output>

<wsdl:fault name="com.sap.xapps.xpd.webservices.exception.BOCreateException">

<soap:fault use="encoded" name="com.sap.xapps.xpd.webservices.exception.BOCreateException" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>

</wsdl:fault>

</wsdl:operation>

</wsdl:binding>

</wsdl:definitions>

Porttypes:

<?xml version="1.0" encoding="utf-8"?>

<!-- Generated by WSDLDefinitionsParser --><wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="urn:com.sap.xapps.xpd.webservices.exception" xmlns:ns0="http://www.w3.org/2001/XMLSchema" xmlns:ns3="urn:com.sap.xapps.xpd.webservices.data" targetNamespace="urn:WSxPDExternalIdeaAttachmentWsd/WSxPDExternalIdeaAttachmentVi/rpc_enc" xmlns:tns="urn:WSxPDExternalIdeaAttachmentWsd/WSxPDExternalIdeaAttachmentVi/rpc_enc" xmlns:ns2="urn:java/lang">

<wsdl:types>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:java/lang" xmlns:tns="urn:java/lang" elementFormDefault="qualified">

<xs:complexType name="ArrayOfString">

<xs:complexContent>

<xs:restriction xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" base="soapenc:Array">

<xs:attribute ref="soapenc:arrayType" wsdl:arrayType="xs:string[]" nillable="true"/>

</xs:restriction>

</xs:complexContent>

</xs:complexType>

</xs:schema>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:com.sap.xapps.xpd.webservices.exception" xmlns:tns="urn:com.sap.xapps.xpd.webservices.exception" elementFormDefault="qualified">

<xs:complexType name="BOCreateException">

<xs:sequence>

<xs:element name="message" type="xs:string" nillable="true" minOccurs="0"/>

</xs:sequence>

</xs:complexType>

</xs:schema>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:com.sap.xapps.xpd.webservices.data" xmlns:tns="urn:com.sap.xapps.xpd.webservices.data" elementFormDefault="qualified" xmlns:s0="urn:java/lang">

<xs:import namespace="urn:java/lang"/>

<xs:complexType name="ExternalIdea">

<xs:sequence>

<xs:element name="title" type="xs:string" nillable="true" minOccurs="0"/>

<xs:element name="description" type="xs:string" nillable="true" minOccurs="0"/>

<xs:element name="classification" type="s0:ArrayOfString" nillable="true" minOccurs="0"/>

<xs:element name="externalAuthor" type="tns:ExternalAuthor" nillable="true" minOccurs="0"/>

</xs:sequence>

</xs:complexType>

<xs:complexType name="ExternalAuthor">

<xs:sequence>

<xs:element name="name" type="xs:string" nillable="true" minOccurs="0"/>

<xs:element name="email" type="xs:string" nillable="true" minOccurs="0"/>

<xs:element name="phone" type="xs:string" nillable="true" minOccurs="0"/>

<xs:element name="country" type="xs:string" nillable="true" minOccurs="0"/>

<xs:element name="zip" type="xs:string" nillable="true" minOccurs="0"/>

<xs:element name="state" type="xs:string" nillable="true" minOccurs="0"/>

<xs:element name="city" type="xs:string" nillable="true" minOccurs="0"/>

<xs:element name="street" type="xs:string" nillable="true" minOccurs="0"/>

</xs:sequence>

</xs:complexType>

</xs:schema>

</wsdl:types>

<wsdl:message name="addIdeaAttachmentIn">

<wsdl:part name="ideaGuid" type="ns0:string"/>

<wsdl:part name="name" type="ns0:string"/>

<wsdl:part name="content" type="ns0:base64Binary"/>

</wsdl:message>

<wsdl:message name="addIdeaAttachmentOut">

<wsdl:part name="Response" type="ns0:boolean"/>

</wsdl:message>

<wsdl:message name="addIdeaAttachment_com.sap.xapps.xpd.webservices.exception.BOCreateException">

<wsdl:part name="addIdeaAttachment_com.sap.xapps.xpd.webservices.exception.BOCreateException" type="ns1:BOCreateException"/>

</wsdl:message>

<wsdl:message name="getIdeaCategoriesIn"/>

<wsdl:message name="getIdeaCategoriesOut">

<wsdl:part name="Response" type="ns2:ArrayOfString"/>

</wsdl:message>

<wsdl:message name="submitIdeaIn">

<wsdl:part name="idea" type="ns3:ExternalIdea"/>

</wsdl:message>

<wsdl:message name="submitIdeaOut">

<wsdl:part name="Response" type="ns0:string"/>

</wsdl:message>

<wsdl:message name="submitIdea_com.sap.xapps.xpd.webservices.exception.BOCreateException">

<wsdl:part name="submitIdea_com.sap.xapps.xpd.webservices.exception.BOCreateException" type="ns1:BOCreateException"/>

</wsdl:message>

<wsdl:portType name="WSxPDExternalIdeaAttachmentVi_Rpc_enc">

<wsdl:operation name="addIdeaAttachment">

<wsdl:input message="tns:addIdeaAttachmentIn"/>

<wsdl:output message="tns:addIdeaAttachmentOut"/>

<wsdl:fault name="com.sap.xapps.xpd.webservices.exception.BOCreateException" message="tns:addIdeaAttachment_com.sap.xapps.xpd.webservices.exception.BOCreateException"/>

</wsdl:operation>

<wsdl:operation name="getIdeaCategories">

<wsdl:input message="tns:getIdeaCategoriesIn"/>

<wsdl:output message="tns:getIdeaCategoriesOut"/>

</wsdl:operation>

<wsdl:operation name="submitIdea">

<wsdl:input message="tns:submitIdeaIn"/>

<wsdl:output message="tns:submitIdeaOut"/>

<wsdl:fault name="com.sap.xapps.xpd.webservices.exception.BOCreateException" message="tns:submitIdea_com.sap.xapps.xpd.webservices.exception.BOCreateException"/>

</wsdl:operation>

</wsdl:portType>

</wsdl:definitions>

Br,

Johannes

Message was edited by: Johannes Mitronen

Read only

Former Member
0 Likes
1,621
  • SAP Managed Tags

hi,

I thought your error message refrred to the SOAP style property which is either DOCUMENT or RPC. E.g. your SOAP message is of RPC style. But that doesn't seem to be the problem.

Maybe the problem is that NW doesn't support WS Security for SOAP with attachments (see <a href="http://help.sap.com/saphelp_erp2005/helpdata/en/31/a6d13f83a14d21e10000000a1550b0/content.htm">help.sap.com</a>)

Client and server platform needed to implement the standard WSA 1.1 (see <a href="http://www.oasis-open.org/committees/download.php/16672/wss-v1.1-spec-os-SwAProfile.pdf">this</a>) which was only approved on Feb. 1st, 2006)

I wish some of the dev people of SAP peeked into our discussions more frequently to clarify actual problems which are hard to judge by us users by trial and error only.

regards,

anton

Read only

Former Member
0 Likes
1,621
  • SAP Managed Tags

Hi Anton,

I did some further investigation under this issue. I decided to try to send raw request directly to server without using SoapClient class. I changed the script as follows:

[code]

<?php

$guid = $_POST['guid'];

$name = $_POST['name'];

$attachment = $_FILES['attachment']['tmp_name'];

$contents = file_get_contents($attachment);

server

$fp = fsockopen("www.foo.bar", 50200, $errno, $errstr, 30);

if (!$fp) {

echo "$errstr ($errno)<br />\n";

} else {

$boundary = "MIME_boundary";

$msg = "--$boundary\r\n";

$msg .= "Content-type: text/xml; charser=UFT-8\r\n";

$msg .= "Content-Transfer-Encoding: 8bit\r\n";

$msg .= "Content-ID: <" . $hash . "xml>\r\n\r\n";

$msg .= "<?xml version=\"1.0\" ?>

<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"

xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"

xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">

<SOAP-ENV:Body SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>

<ns1:addIdeaAttachment xmlns:ns1='urn:WSxPDExternalIdeaAttachmentVi'>

<ideaGuid xsi:type='xs:string'>$guid</ideaGuid>

<name xsi:type='xs:string'>$name</name>

<content href='cid:" . $hash . "attachment'></content>

</ns1:addIdeaAttachment>

</SOAP-ENV:Body>

</SOAP-ENV:Envelope>\r\n\r\n";

$msg .= "--$boundary\r\n";

$msg .= "Content-type: application/octetstream\r\n";

$msg .= "Content-Transfer-Encoding: binary\r\n";

$msg .= "Content-ID: <" . $hash . "attachment>\r\n\r\n";

$msg .= "$contents\r\n";

$msg .= "$boundary";

$length = strlen($msg);

$head = "POST /WSxPDExternalIdeaAttachment/EIAttachmentConfig?style=mime HTTP/1.1\r\n";

$head .= "Host: www.foo.bar:50200\r\n";

$head .= "Content-Type: multipart/related; type=text/xml; boundary=$boundary\r\n";

$head .= "Connection: close\r\n";

$head .= "Authorization: Basic " . base64_encode("xxx:xxx") . "\r\n";

$head .= "Content-Length: $length\r\n";

$head .= "SOAPAction: \"\"\r\n";

$head .= "\r\n";

$out = $head . $msg;

fwrite($fp, $out);

while (!feof($fp)) {

echo fgets($fp, 128);

}

fclose($fp);

}

?>

[/code]

Now the message which is sent to the server looks like this:

POST /WSxPDExternalIdeaAttachment/EIAttachmentConfig?style=mime HTTP/1.1

Host: www.foo.bar:50200

Content-Type: multipart/related; type=text/xml; boundary=MIME_boundary

Connection: close

Authorization: Basic eHBkX2lkZWE6eHBkX2lkZWE=

Content-Length: 967

SOAPAction: ""

--MIME_boundary

Content-type: text/xml; charser=UFT-8

Content-Transfer-Encoding: 8bit

Content-ID: <9dd3ecb681xml>

<?xml version="1.0" ?>

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">

<SOAP-ENV:Body SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>

<ns1:addIdeaAttachment xmlns:ns1='urn:WSxPDExternalIdeaAttachmentVi'>

<ideaGuid xsi:type='xs:string'>ae85b9f0-db5a-11da-a2b2-00e000c4ea35</ideaGuid>

<name xsi:type='xs:string'>nootit.txt</name>

<content href='cid:9dd3ecb681attachment'></content>

</ns1:addIdeaAttachment>

</SOAP-ENV:Body>

</SOAP-ENV:Envelope>

--MIME_boundary

Content-type: application/octetstream

Content-Transfer-Encoding: binary

Content-ID: <9dd3ecb681attachment>

...file content...

MIME_boundary

And I'm getting this response back:

HTTP/1.1 200 OK

Connection: close

Set-Cookie: JSESSIONID=(J2EE23521500)ID0020989350DB22113200698559606145End; Version=1; Domain=.foo.bar; Path=/

Set-Cookie: saplb_*=(J2EE23521500)23521550; Version=1; Path=/

Server: SAP J2EE Engine/7.00

Content-Type: text/xml; charset=UTF-8

Date: Thu, 04 May 2006 10:44:35 GMT

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >

<SOAP-ENV:Body>

<rpl:addIdeaAttachmentResponse xmlns:rpl='urn:WSxPDExternalIdeaAttachmentVi'>

<rpl:Response SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' xsi:type='xs:boolean'>true</rpl:Response>

</rpl:addIdeaAttachmentResponse>

</SOAP-ENV:Body>

</SOAP-ENV:Envelope>

Looks fine but oly problem is that the attachment is not found when I open the corresponding idea on xPD. J2EE logs doesn't show anything suspicious...

Any ideas why this could happen? One thing which comes to my mind is that I'm submitting the idea in the first phase using webservice WSxPDService and then I'm calling a different service WSxPDExternalIdeaAttachment to upload attachments. Does this make any sense to you?

Br,

Johannes

Message was edited by: Johannes Mitronen

Read only

Former Member
0 Likes
1,621
  • SAP Managed Tags

maybe it's just that your mime boundary declaration is wrong?

Content Type: [...] boundary="MIME_boundary"

whereas the real boundary is

--MIME_boundary

I'll look into it deeper a little later.

anton

Read only

Former Member
0 Likes
1,621
  • SAP Managed Tags

Hi Anton,

mime boundary should be fine.

I did some more testing. It seems that when I test this webservice on Web Service Navigator it does not work either (same result, no attachment found).

I will open a customer message. Thank you for your help!

Br,

Johannes

Read only

Former Member
0 Likes
1,621
  • SAP Managed Tags

Hi Johannes,

have you been able to clarify the InvalidSecurity issue?

If yes, how?

I´m facing the same Problem with the message "WS Security can only be applied on a SOAP document" although security profile "None" is applied to the webservice.

Regards

Gabi