Sending a byte array from PHP to WCF

喜欢而已 提交于 2019-11-30 15:54:08

You should use strings in PHP to emulate byte arrays. You can even use the syntax $str[index] with strings. You have a HUGE overhead (4x or 8x depending on the int size the payload PLUS the hash table overhead) otherwise.

I'm not very familiar with the type conversions the SOAP extension does, but using a string instead will probably work.

EDIT: Just checked the sources:

if (Z_TYPE_P(data) == IS_STRING) {
    str = php_base64_encode((unsigned char*)Z_STRVAL_P(data), Z_STRLEN_P(data), &str_len);
    text = xmlNewTextLen(str, str_len);
    xmlAddChild(ret, text);
    efree(str);
}

So it already does the base 64 encoding for you.

EDIT2: [SPECULATION]

Your 5-byte long result is because of the conversion to string that follows the code above:

if (Z_TYPE_P(data) == IS_STRING) {
        ...
} else {
    zval tmp = *data;

    zval_copy_ctor(&tmp);
    convert_to_string(&tmp);
    str = php_base64_encode((unsigned char*)Z_STRVAL(tmp), Z_STRLEN(tmp), &str_len);
    text = xmlNewTextLen(str, str_len);
    xmlAddChild(ret, text);
    efree(str);
    zval_dtor(&tmp);
}

The conversion results in "Array", which is 5 bytes long.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!